Get_called_class -- the name of the late static binding ("late static binding") class
string Get_called_class ( void )
Gets the class name of the static method call.
returns the name of the class, if not called in the class. FALSE .
<?php
classperson{
Public$username;
Public$age;
Public$height;
Public$weight;
Static Public= 0;
Publicfunction__construct ($username,$age,$height,$weight){
$this->username =$username;
$this->age =$age;
$this->height =$height;
$this->weight =$weight;
Self::++;
}
Publicfunction__set ($name,$value){
$this-$name=$value;
}
Publicfunction__get ($name){
return$this-$name;
}
/**
* 1) Non-static members cannot be used directly in the static method because non-static members are related to the instance and are indirectly used by instantiation
* 2) This cannot be used in the static method (related to the instance)
* 3) Static members can be used in non-static methods
*/
Static PublicfunctionGetusernumber () {
Var_dump(Get_called_class ());
returnSelf::;
}
PublicfunctionGetUserName () {
Var_dump(Get_called_class ());
return$this->username;
}
Publicfunction__tostring () {
return‘‘;
}
}
$p _person1=NewPerson (' Zhaofei ', 23,185,62);
Echo$p _person1->getusername ();
$p _person2=NewPerson (' zhaofei1 ', 24,165,68);
$p _person3=NewPerson (' Zhaofei2 ', 23,180,82);
$p _person4=NewPerson (' Zhaofei3 ', 22,175,72);
EchoPerson::getusernumber ();
?>
get_called_class--Late static binding ("late static binding") class name