How to access Variable in parent class using parent:: method
<p>I have Protected Variable UserId in Parent Class.i Am going to extend the variable in my child class as shown below</p>

<pre><code>class Main
{
  protected $UserId          = "151";
  protected static $UserName = "Madhavan";      

  protected function SampleMethod()
  {
    print "This is Sample Method";
  } 
}


class SubMain extends Main
{   
  function __construct()
  {    
    print parent::SampleMethod();

    print "User Id is ".$this-&gt;UserId."&lt;br/&gt;";          
    print parent::$UserName;
    print "User Id is ".parent::$UserId."&lt;br/&gt;";            
  }
}
</code></pre>

<p>When I Use <strong>$this->UserId</strong> Its printing fine.But when I use Parent::$UserId its displaying error </p>

<p><em>Fatal error: Access to undeclared static property: Main::$UserName</em></p>

<p>Why it is not showing for the function which i Accessed by <strong>parent::SampleMethod()</strong> as the function is not static.</p>
