Example #1
0
		}


	}

	class Akash extends Person
	{
		public function __construct($name, $surname, $age){
			echo $this->name;
			parent::__construct($name, $surname, $age);
			echo $this->name;
			echo "I am Child, MF!<br />";
		}
	}

	$person = new Akash("Akash", "Sinha", 23);
	$person->statFunc();













<?php 

// if not instantiated, the "self" keyword refers to the highest(parent) class in the inheritance.

class Person
{
	static protected $stmt = "Hi there, wassap?";

	static public function getStmt()
	{
		//return self::$stmt;			// to deal with the below problem we use "static" keyword instead of "self".
		return static::$stmt;
	}
}

class Akash extends Person
{
	static protected $stmt = "Hi I'm Akash and I love chicken.";
}


echo Akash::getStmt() . "<br />"; //expected output is "Hi I'm Akash and I love chicken.". but its not the output. The output is "Hi there, wassap?".






 ?>