The examples in this article describe the definition and inheritance usage of PHP classes. Share to everyone for your reference. as follows:
<?php * * Class/class people {public $name;
Public $age;
function __construct ($namec, $agec) {$this->name = $namec;
$this->age = $agec; protected function GetMessage () {return "name:". $this->name. " <br/> "."
Age: ". $this->age; function __tostring () {return "name:". $this->name. " <br/> "."
Age: ". $this->age; function __destruct () {echo <br/> I am dead!
";
function __call ($key, $args) {echo "<br/>", "You call the method name does not exist: $key", "<br/>";
echo "You call the parameter is:", Var_dump ($args);
Final function getf () {echo "I am GETF";
Class Xinxin extends People {function getname () {echo $this->getmessage ();
Echo ' <br/> ';
Echo Parent::getmessage ();
Echo ' <br/> ';
Return "I am Xinxin";
function GetMessage () {return "I am zilei getmessage <br/>";
function GETFF () {echo "I am New GETF";
} $pp = new People ("younger brother", "33"); $PP->name = "Xiaoming ";
$PP->age = "88";
Echo $pp->name;
Echo ';
Echo $pp->age;
Echo ' <br/><br/> ';
$xx = new Xinxin ("small", "13");
echo $xx->getname ();?>
I hope this article will help you with your PHP programming.