title: PHP: Comparison within Assignment Statement
body: <p>In my never-ending quest to optimise my line usage, I've just got a quick question about what exactly can go into as assignment statement in PHP (and other languages too, but I'm working on a PHP project).</p>
  
  <p>In my program I have a certain boolean variable, which is toggled by a few things summarised by an if statement. I thought, hang on, that if statement will evaluate to a boolean value, can I just use that logic in one line, as opposed to wrapping a separate assignment statement inside the if. Basically my question is will:</p>
  
  <pre><code>$myVar = ($a == $b);
  </code></pre>
  
  <p>be equivalent to</p>
  
  <pre><code>if ($a == $b) { $myVar = true; }
  else { $myVar = false; }
  </code></pre>
  
  <p>As you can see, this saves me <em>one whole line</em>, so it will impact my project hugely. /sarcasm</p>