I have a below PHP statement:
if(
(bool)is_check1($a) ||
(bool)is_check2($a) ||
(bool)is_check3($a)
){
callFunctionA();
}
I have debugged and got a news thing so strange that, even if is_check1 returns TRUE, PHP still invoke the functions: is_check2, and is_check3.
In my mind, I always think that, if is_check1 function returns TRUE, PHP SHOULD not invoke others.
But when I check it again, for example:
if(
TRUE ||
(bool)is_check2($a) ||
(bool)is_check3($a)
){
callFunctionA();
}
The result is: is_check2 and is_check3 function do not invoke.
Please give me your advice to optimize in this case or am I missing something?
Attempting to reproduce with the following code:
Prints:
avalid!valid!avalid!That means the problem is probably the return values of your functions.