title: PHP best way to check whether a string is empty or not
body: <p>I've seen a lot of php code that does the following to check whether a string is valid by doing:</p>
  
  <p>$str is a string variable.</p>
  
  <pre><code>if (!isset($str) || $str !== '') {
    // do something
  }
  </code></pre>
  
  <p>I prefer to just do</p>
  
  <pre><code>if (strlen($str) &gt; 0) {
    // something
  }
  </code></pre>
  
  <p>Is there any thing that can go wrong with the second method?  Are there any casting issues I should be aware of?</p>