I have a validation function that I want to return true if the validation passes, or an array of errors if validation fails. However, when I check if the function returns true, it returns true even if the returned value is an array. Why is this? As a further example of what I mean:
$array = ['test' => 'test'];
if ($array == true)
{
echo 'true';
}
and I also tried the same with a string:
$string = 'string';
if ($string == true)
{
echo 'true';
}
And both echo true.
Why is this? And if we can do this then why do we need the isset() function?
count()for array, if it is 0 then it is false$variablesor empty string will return true. unless you declare your$variablesas false.