get_class_vars--returns an array that consists of the default properties of the class

Source: Internet
Author: User

Get_class_vars -- returns an array that consists of the default properties of the class

get_ Class_vars   (  string   $class _name  )

returns the default by the class Public Properties An associative array of elements of this array that varname = value the form exists.

<?php
classperson{
Public $username;
Public$age;
Public$height;
Public$weight;
Static Public$number= 0;

Publicfunction__construct ($username,$age,$height,$weight){
$this->username =$username;
$this->age =$age;
$this->height =$height;
$this->weight =$weight;
Self::$number++;
}
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::$number;
}

PublicfunctionGetUserName () {
Var_dump(Get_called_class ());
return$this->username;
}

Publicfunction__tostring () {
return‘‘;
}
}
Var_dump(Get_class_vars(' person '));

?>

get_class_vars--returns an array that consists of the default properties of the class

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.