title: PHP: Using is_null() with !$var or isset($var)
body: <p>While I believe the answer is <em>yes</em>, I have seen the following in legacy code so much, I'm doubting myself. I'm asking for a sanity check from the community.</p>
  
  <h3>Legacy Code</h3>
  
  <pre><code>if (is_null($result) || !$result) {
  </code></pre>
  
  <h3>Refactored Code</h3>
  
  <pre><code>if (!$result) {
  </code></pre>
  
  <p><strong><em>Note:</strong> I am aware this will throw a Notice if <code>$result</code> is not set.</em></p>
  
  <h3>Question</h3>
  
  <p>Is this code logically equivalent?</p>
  
  <h3>Code Tests</h3>
  
  <p>I tested with all the combinations of <a href="http://php.net/manual/en/language.types.boolean.php" rel="nofollow noreferrer">PHP false values</a> without receiving <em>Not equal for ...</em>.</p>
  
  <pre><code>$false_values = array(false, 0, 0.0, '0', '', null, array(), new stdClass());
  
  foreach ($false_values as $var) {
      if (!$var != (is_null($var) || !$var)) {
          echo 'Not equal for: ';
          var_dump($var);
      }
  }
  </code></pre>
  
  <h3>Output</h3>
  
  <pre><code>$ php check.php
  $
  </code></pre>