Answer the question
In order to leave comments, you need to log in
Are there any side effects in PHP (theoretically) when initializing a variable in an if condition?
Faced a problem.
I am making a plugin on Livestreet (CMS), and I have the following type of code.
if($sFileWebFoto=somefunc() &&
$sFileWebAvatar=somefunc()) {
//...
}
Answer the question
In order to leave comments, you need to log in
You asked if PHP has any side effects. Available.
If the first condition is false, then the second condition will not even run at all:
function first() { echo "first "; return false; }
function second() { echo "second "; return true; }
if (first() && second()) echo "OK"; else echo "Bad";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question