I'm looking for information about how expressions are evaluated in PHP.
As an example, if I have the following
if (a || b)
If "a" evaluates to true, does php skip the evaluation of "b" or does it evaluate "b" even though the statement as a whole is true irregardless of what "b" is.
The reason that I am asking is that I have a situation where I have
if (a || doFunctionA())
if "a" evaluates to true then there is no reason to call the function "doFunctionA" as this would perform a function that had already been performed elsewhere in the script and there is no need to perform the same actions again.
I've been looking in the documentation on php.net, but have not been able to find anything.
I realize that this is a yes or no question, but I don't want a simple yes or no. What I want is some official documentation to tell me how it works, rather than assumptions (My assumption is that the second part would no be evaluated, but my assumption could be wrong). Would appreciate any links to this information in the official documentation.
Thanks
Start Free Trial