These two lines produce different results:
$r1= true xor true ;
$r2=(true xor true);
var_dump($r1);
var_dump($r2);
Output:
bool(true)
bool(false)
Why?
Codepen example: http://codepad.org/O4Kn1YVa
These two lines produce different results:
$r1= true xor true ;
$r2=(true xor true);
var_dump($r1);
var_dump($r2);
Output:
bool(true)
bool(false)
Why?
Codepen example: http://codepad.org/O4Kn1YVa
http://php.net/manual/en/language.operators.precedence.php
= is higher priority than xor
$r1 = true xor true ;
=>
($r1 = true) xor true ; // "=" has highest priority
=>
$r1 xor true ; // and only now xor
In this case you do not write result of xor anywhere and have lost it.
In case with result 2 you are forcing the execution order by parentheses.