What I want to understand -
$x = true and false;
var_dump($x);
Answer comes out to be as boolean(true);
But under algebra i have been learning as 1 and 0 is 0
Ran the code in php
What I want to understand -
$x = true and false;
var_dump($x);
Answer comes out to be as boolean(true);
But under algebra i have been learning as 1 and 0 is 0
Ran the code in php
 
    
     
    
    and has a lower operator precedence than = so what you are executing is:
($x = true) and false;
So the complete expression - which you don't use the result of - will return false, but $x will be true.
 
    
    It is because the and operator does not work as you think: 'AND' vs '&&' as operator
Basically, = has higher precedence.
$x = false && true;
var_dump($x);
returns bool(false).
As does
$x = (false and true);
 
    
    