I'm trying to understand the behavior of or operator. Please see the below examples: 
$e = false || true;
var_dump($e);
Output is as expected: bool(true);
$f = false or true;
var_dump($f);
Output is as expected: bool(false). I understood this in a way that the = has a higher precedence than the Or, so that's why the $f is assigned to false.
But the below code works quite opposite of what I thought. I thought that the $foo will be assigned to 5 and then compared to itself.
But the $foo is getting assigned only when if the $foo is set that means it is checking if the $foo is assigned to anything before, assign 5 to it.
$foo or $foo = 5; 
Can anyone explain why this is so?
 
     
     
     
     
    