PHP get_class_methods function usage

Source: Internet
Author: User

PHP get_class_methods function usage

The get_class_methods function returns an array composed of class method names. This article will briefly share the usage of this function.

Function prototype array get_class_methods (mixed $ class_name)

Returns an array of method names defined in the class specified by class_name. If an error occurs, NULL is returned.

Note: from PHP 4.0.6, you can specify the object itself to replace class_name. The following is an example of get_class_methods:

<?phpclass myclass {// constructorfunction myclass() {return(true);}// method 1function myfunc1() {return(true);}// method 2function myfunc2() {return(true);}}$class_methods = get_class_methods('myclass');// or$class_methods = get_class_methods(new myclass());foreach ($class_methods as $method_name) {echo $method_name,'<br />';}

The above example will output:

Myclass
Myfunc1
Myfunc2

Note:

Since PHP 5, this function is returned (case sensitive) according to the name defined by the method ). PHP 4 always returns lowercase letters.

Articles you may be interested in
  • Php uses the session_set_save_handler () function to save the session to the MySQL database.
  • Functions and usage of the php get_headers Function
  • Simulate the get_headers function in php.
  • Comparison of file_get_contents with curl in PHP
  • PhpMyAdmin Cannot start session without errors error Solution
  • Php get_headers determines whether the URL is valid
  • Obtain the function of the sub-class_id set
  • Php mktime Function Analysis

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.