title: Why does empty("0") returns true in PHP?
body: <p>According to PHP documentation, the following expressions return true when calling <code>empty($var)</code></p>
  <ul>
  <li>&quot;&quot; (an empty string)</li>
  <li>0 (0 as an integer)</li>
  <li>0.0 (0 as a float)</li>
  <li><strong>&quot;0&quot; (0 as a string)</strong></li>
  <li>NULL</li>
  <li>FALSE</li>
  <li>array() (an empty array)</li>
  <li>$var; (a variable declared, but without a value)</li>
  </ul>
  <p>I've found how to &quot;solve&quot; the problem by using <code>empty($var) &amp;&amp; $var != 0</code> but why php developers did it?</p>
  <p>I think it is ridiculous, suppose you have this code:</p>
  <pre><code>if (empty($_POST[&quot;X&quot;])) {
      doSomething();
  }
  </code></pre>
  <p>I think <code>&quot;0&quot;</code> is not empty, empty is when there is nothing!</p>
  <p>Maybe it's better to use</p>
  <pre><code>if (isset($x) &amp;&amp; x != &quot;&quot;) {//for strings
      doSomething();
  }
  </code></pre>