title: Null coalescing operator in if-condition
body: <p>I'm being confused as to how the null coalescing operator in PHP works and I'd like some explanation for the following if possible:</p>
  <p>I have an associative array representing data posted to the server. One of the values in that array can either be a boolean or just simply not set. I'm using that value in an if-condition that checks for that value being present &amp; set to <code>true</code> and one other condition. The way I do the checking for the value being present is that I use the null coalescing (<code>??</code>) operator to replace the missing value with <code>false</code>.</p>
  <p>This seems to change the result of the if-condition. As long as the condition is present, the if condition returns <code>true</code>, regardless of the second part of my if condition.</p>
  <p>How is this possible?</p>
  <pre><code>&lt;?php
  
  $body = [];
  $body['variable'] = true;
  if ($body['variable'] ?? false &amp;&amp; false) {
      echo('true');
  } else {
      echo('false');
  }
  
  // true
  
  unset($body['variable']);
  if ($body['variable'] ?? false &amp;&amp; false) {
      echo('true');
  } else {
      echo('false');
  }
  
  // false
  </code></pre>