I have Protected Variable UserId in Parent Class.i Am going to extend the variable in my child class as shown below
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->UserId."<br/>";
print parent::$UserName;
print "User Id is ".parent::$UserId."<br/>";
}
}
When I Use $this->UserId Its printing fine.But when I use Parent::$UserId its displaying error
Fatal error: Access to undeclared static property: Main::$UserName
Why it is not showing for the function which i Accessed by parent::SampleMethod() as the function is not static.