title: PHP: check if a property doesn't exist or its value is an empty string
body: <p>This probably has been asked, but I couldn't find the exact answer I am seeking.</p>
  
  <p>In javascript, I can simply do</p>
  
  <pre><code>if (a.b) {//do something}
  </code></pre>
  
  <p>But in PHP, if I do</p>
  
  <pre><code>if($a-&gt;b) {}
  </code></pre>
  
  <p>Basically it'll work, but I will get a notice if <code>a</code> has no <code>b</code>, so I switch to </p>
  
  <pre><code>if(isset($a-&gt;b)){}
  </code></pre>
  
  <p>That doesn't work because when <code>a-&gt;b</code> is an empty string, it will return true. So I ended up doing</p>
  
  <pre><code>if(isset($a-&gt;b) &amp;&amp; $a-&gt;b !== ''){}
  </code></pre>
  
  <p>This seems redundant and not very bug-proof. </p>
  
  <p>What is the best practice to do this?</p>