php __get method and visbility types behavior
<pre><code>class Magic{
    public $a="i";
    public $b=array("a"=&gt;"A","b"=&gt;"B","c"=&gt;"C");
    public $c=array(1,2,3);

    public function __get($v)
    {
     echo "&lt;br/&gt;get-&gt;$v";
     return $this-&gt;b[$v];
    }

    public function __set($var,$val)
    {
    echo "&lt;br/&gt;set-&gt;$var: $val,";
    $this-&gt;$var=$val;
    }
    }

    $m=new Magic();
    echo $m-&gt;a." , ".$m-&gt;b." ,".$m-&gt;c." ,";
    $m-&gt;c="CC";
    echo $m-&gt;a." , ".$m-&gt;b." ,".$m-&gt;c;
</code></pre>

<p><strong>Output</strong>:i , Array ,Array ,i , Array ,CC</p>

<p>Now, I modify the visibility to protected for variable $b and $c.</p>

<p><strong>Output</strong>: bci , B ,C ,c: CC,bci , B ,C</p>

<p>As far as I understand _<em>get and</em>_set is called for undefined var .So, when access modifier or visibility is set to protected why __get() is called !.</p>

<p>Can someone explain ..... I am not able to understand this.</p>
