Why is property null when its value is assigned using __get()?
<p>I've made a class:</p>

<pre><code>class MyClass {
    function __get($name) {
        $this-&gt;{$name} = $_SESSION[$name];
    }

    public function isNull(){
        return $this-&gt;MyVar === null;
    }
}
</code></pre>

<p><code>var_dump($obj-&gt;isNull()) //$obj is instance of MyClass</code> always outputs <code>bool(true)</code> doesn't matter <code>$_SESSION['MyVar']</code> is set or not. But if I add <code>$this-&gt;MyVar;</code> before <code>return $this-&gt;MyVar === null;</code> works as expected.</p>

<p>Well it seems that <code>__get()</code> is executed (because <code>$MyVar</code> is not set so it's inaccessible) but property stays NULL until second usage.</p>

<p>Does it happen because it's not set at all? How can I avoid using extra line (<code>$this-&gt;MyVar;</code>)?</p>
