Home > Article > Backend Development > PHP function method to obtain and check class name, function name, method name_PHP tutorial
This article mainly introduces the functions of PHP to obtain and check class names, function names, and method names. Method, this article summarizes the functions and usage of 7 functions. Friends in need can refer to it
1.function_exists() - Return TRUE if the given function has been defined
2.is_callable() - Check whether the parameter is a legal callable structure
3.class_exists() - Check whether the class has been defined
4.method_exists() - Check whether the class method exists
__FUNCTION__ function name (newly added in PHP 4.3.0). Since PHP 5 this constant returns the name of the function when it was defined (case sensitive). In PHP 4 this value is always lowercase.
__CLASS__ The name of the class (newly added in PHP 4.3.0). Since PHP 5 this constant returns the name of the class when it was defined (case sensitive). In PHP 4 this value is always lowercase.
__METHOD__ The method name of the class (newly added in PHP 5.0.0). Returns the name of the method as it was defined (case-sensitive).
Note: These constants are preceded and followed by two underscores.
get_class(class name);//Get the class name of the class where the current statement is located
get_class_methods(class name);//Get all the method names of class name and form an array
get_class_vars(class name);//Get all the highlighted names of class name and form an array