I have a problem that’s driving me crazy.
I have a static class where I perform some checks, this is the code:
class MyClass
{
public static function globalChecks()
{
$result = true;
$result = $result && self::checkAgency();
$result = $result && self::checkAttribs();
$result = $result && self::checkCategories();
$result = $result && self::checkDistricts();
$result = $result && self::checkTowns();
$result = $result && self::checkTypes();
$result = $result && self::checkUser();
return $result;
}
}
All of these methods are declared as public and static.
Well if I try to run it, PHP executes the first one, then it simply skips the other ones.
I tried to debug or brutally put a die() inside the method, but it doesn’t work.
If I switch the variable with the method call (ie self::method && $result) everything works…
It seems operator precedence is involved in some way, but am I missing something?
as soon as one of your method call will return false, the && operation won’t execute the second part of the expression ! since False && anything is False.