bwoogie wrote:Is it checking the value of $var or that $var was set to myFunc's result successfully?
An assignment operation [font=monospace]=[/font] evaluates to the value of whatever is on its right-hand side. At the same time, it sets the variable on the left hand side to the same value. So the if() test is checking the value of whatever was put into $var.
bwoogie wrote:myFunc returns true on success or a string $err if it fails. But that statement is always returning true no matter what myFunc returns.
Only a few values are considered equivalent to false in an if() test; everything else is true.
If the function returns values of different types depending on what happened, you can tell what happened by looking at the type of the returned value.
$var = myFunc($a, $b, $c, $d);
if(is_string($var))
{
// $var contains an error message
}
else
{
// $var contains something else (a boolean, presumably)
}