get_called_class--Late static binding ("late static binding") class name

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.