title: PHP: what's an alternative to empty(), where string "0" is not treated as empty?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/410002/fixing-the-php-empty-function">Fixing the PHP empty function</a>  </p>
  </blockquote>
  
  
  
  <p>In PHP, empty() is a great shortcut because it allows you to check whether a variable is defined AND not empty at the same time.</p>
  
  <p>What would you use when you don't want "0" (as a string) to be considered empty, but you still want false, null, 0 and "" treated as empty?</p>
  
  <p>That is, I'm just wondering if you have your own shortcut for this:</p>
  
  <pre><code>if (isset($myvariable) &amp;&amp; $myvariable != "") ;// do something
  if (isset($othervar  ) &amp;&amp; $othervar   != "") ;// do something
  if (isset($anothervar) &amp;&amp; $anothervar != "") ;// do something
  // and so on, and so on
  </code></pre>
  
  <p>I don't think I can define a helper function for this, since the variable could be undefined (and therefore couldn't be passed as parameter).</p>