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