Pretty rhythm Dear my future PHP get the implementation code for the properties and methods of a class

Source: Internet
Author: User
Copy the Code code as follows:


class MyClass {
var $var 1;
var $var 2 = ' xyz ';
var $var 3 = 100;
Private $var 4;
function MyClass () {
$this->val1 = "Foo";
$this->val2 = "Bar";
return true;
}
function Test1 () {
return true;
}
}
Get_class_methods () returns an array of the method names of the class
Get_class_methods (' MyClass ') or Get_class_methods (new MyClass ());
Get_class () returns the class name of the object
Get_class_vars () returns an array of default properties of the class
$my _class = new MyClass ();
$class _vals = Get_class_vars (Get_class ($my _class));
foreach ($class _vars as $name = + $value) {
echo "$name: $value \ n
";
}
?>

The above describes the pretty rhythm dear my future php to obtain a class of properties and methods of implementation code, including pretty rhythm dear my content, I hope to be interested in PHP tutorial friends helpful.

  • 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.