title: PHP: empty doesn't work with a getter method
body: <p>I have a "getter" method like</p>
  
  <pre><code>function getStuff($stuff){
    return 'something';
  }
  </code></pre>
  
  <p>if I check it with <code>empty($this-&gt;stuff)</code>, I always get <code>FALSE</code>, but I know <code>$this-&gt;stuff</code> returns data, because it works with echo.</p>
  
  <p>and if I check it with <code>!isset($this-&gt;stuff)</code> I get the correct value and the condition is never executed...</p>
  
  <p>here's the test code:</p>
  
  <pre><code>class FooBase{
  
    public function __get($name){
      $getter = 'get'.ucfirst($name);
      if(method_exists($this, $getter)) return $this-&gt;$getter();
      throw new Exception("Property {$getter} is not defined.");
    }
  }
  
  class Foo extends FooBase{
    private $my_stuff;
  
    public function getStuff(){
      if(!$this-&gt;my_stuff) $this-&gt;my_stuff = 'whatever';
      return $this-&gt;my_stuff;
    }
  
  }
  
  $foo = new Foo();
  echo $foo-&gt;stuff;
  
  if(empty($foo-&gt;stuff)) echo 'but its not empty:(';
  if($foo-&gt;stuff) echo 'see?';
  </code></pre>