title: Checking for a null value in conditional in PHP
body: <p>I have found there to be multiple ways to check whether a function has correctly returned a value to the variable, for example:</p>
  
  <h3>Example I</h3>
  
  <pre><code>$somevariable = '';
  
  $somevariable = get_somevariable();
  
  if ($somevariable)
  {
      // Do something because $somevariable is definitely not null or empty!
  }
  </code></pre>
  
  <h3>Example II</h3>
  
  <pre><code>$somevariable = '';
  
  $somevariable = get_somevariable();
  
  if ($somevariable &lt;&gt; '')
  {
      // Do something because $somevariable is definitely not null or empty!
  }
  </code></pre>
  
  <p>My question: what is the best practice for checking whether a variable is correct or not? Could it be different for different types of objects? For instance, if you are expecting $somevariable to be a number, would checking if it is an empty string help/post issues? What is you were to set $somevariable = 0; as its initial value?</p>
  
  <p>I come from the strongly-typed world of C# so I am still trying to wrap my head around all of this.</p>
  
  <p>William</p>