Home >Backend Development >PHP Tutorial >PHP uses the get_class_methods function to obtain classification methods

PHP uses the get_class_methods function to obtain classification methods

WBOY
WBOYOriginal
2016-07-27 16:56:181061browse

The example in this article describes how PHP uses the get_class_methods() function to obtain classification. Share it with everyone for your reference, the details are as follows:

<&#63;php
/*
 * Created on 2016-7-20
 */
class Window    //首先定义一个类
{
 var $state;    //窗户的状态
 function close_window()   //关窗户方法
 {
 $this->state="close";   //窗户的状态为关
 }
 function open_window()   //开窗户方法
 {
 $this->state="open";   //窗户的状态为开
 }
}
$temp=get_class_methods("Window");
echo "类Window中的方法有以下几个:";
echo "<p>";
for($i=0;$i<count($temp);$i++)
{
 echo $temp[$i].",";
}
&#63;>

The running results are as follows:

The methods in class Window are as follows:
close_window, open_window,

Readers who are interested in more PHP-related content can check it out Special topics on this site: "Introduction Tutorial on PHP Object-Oriented Programming", "Summary of PHP Mathematical Operation Skills", "Complete PHP Array (Array) Operation Skills", "Summary of PHP String Usage", "PHP Data Structure and Algorithm" Tutorial", "Summary of PHP Programming Algorithm", "Summary of PHP Regular Expression Usage", and "Summary of PHP Common Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

The above introduces how PHP uses the get_class_methods function to obtain classification, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn