I can't figure this out.
If I type:
function myfunction(){
......
if ...
return TRUE;
if ...
return FALSE;
}
Why can't I use it like this:
$result = myfunction();
if ($result == TRUE)
...
if ($result == FALSE)
...
Or do I have to use:
$result = myfunction();
if ($result == 1)
...
if ($result == 0)
...
Or this:
$result = myfunction();
if ($result)
...
if (!$result)
...
if … return true; else return false;should always be rewritten toreturn … === true;or, in a type-safe language, simply toreturn …;. Theifsimply makes no sense here, since the condition we are testing already corresponds to the return value.