let's say I have something like this:
if(1 == 0 && do_stuff()) {
...
}
Obviously 1 is not 0, so there's no point to check the other condition. So does PHP ever run do_stuff() ?
let's say I have something like this:
if(1 == 0 && do_stuff()) {
...
}
Obviously 1 is not 0, so there's no point to check the other condition. So does PHP ever run do_stuff() ?
No - PHP uses lazy evaluation (sometimes called short-circuit evaluation), so if the first condition in a logical AND is false, it won't attempt to evaluate any of the other conditions.
Likewise, if you were doing an OR and the first condition was true it wouldn't evaluate the second.
$debug in production). Then another approach is to put the the test, that will most likely fail, to the left.