title: Boolean assignment operators in PHP
body: <p>I find myself doing this kind of thing somewhat often:</p>
  
  <pre><code>$foo = true;
  $foo = $foo &amp;&amp; false; // bool(false)
  </code></pre>
  
  <p>With bitwise operators, you can use the <code>&amp;=</code> and <code>|=</code> shorthand:</p>
  
  <pre><code>$foo = 1;
  $foo &amp;= 0; // int(0)
  </code></pre>
  
  <p>Given that bitwise operations on <code>1</code> and <code>0</code> are functionally equivalent to boolean operations on <code>true</code> and <code>false</code>, we can rely on type-casting and do something like this:</p>
  
  <pre><code>$foo = true;
  $foo &amp;= false; // int(0)
  $foo = (bool)$foo; // bool(false)
  </code></pre>
  
  <p>...but that's pretty ugly and defeats the purpose of using a shorthand assignment syntax, since we have to use another statement to get the type back to boolean.</p>
  
  <p>What I'd really like to do is something like this:</p>
  
  <pre><code>$foo = true;
  $foo &amp;&amp;= false; // bool(false)
  </code></pre>
  
  <p>...but <code>&amp;&amp;=</code> and <code>||=</code> are not valid operators, obviously.  So, my question is - is there some other sugary syntax or maybe an obscure core function that might serve as a stand-in?  With variables as short as <code>$foo</code>, it's not a big deal to just use <code>$foo = $foo &amp;&amp; false</code> syntax, but array elements with multiple dimensions, and/or object method calls can make the syntax quite lengthy.</p>