PHP seems to be evaluating an if statement backwards [duplicate]
You have operator precedence issue. Check this http://www.php.net/manual/en/language.operators.precedence.php
Because ||
has higher precedence than =
Your expression really looks like this
if ( $x = ( function($y) || ( $z == 50 ) ) )
Instead of (what I think was your intention)
if ( ($x = function($y)) || ($z == 50) )
||
has higher precedence than =
, which means your expression becomes:
$x = (foo($y) || ($z == 50));
This means that $x
will always be either true
or false
. Nothing else.
Try:
if( ($x = foo($y)) || ($z == 50))
Or, more readable:
$x = foo($y);if( $x || $z == 50)