The following editor will bring you a brief discussion of the related functions of classes and objects in PHP. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look
class_exists
To determine whether a class exists, the parameter is a name!
interface_exists
To determine whether an interface exists, the parameter is also a name!
method_exists
Determine whether a method exists!
Requires two: the first object variable, the second is a method name! Return a boolean value!
To determine whether aattributeexists, use isset
get_class
Get the class to which the current object belongs!
The parameter is an object!
get_parent_class
Get the parent class name of the object!
get_class_methods
Requires one parameter for a class name and returns an index array with the elements inside It is a collection of method names!
You can get all the public methods of your own and inherited parent classes (staticmethods and non-static methods can be obtained), but outside the class Cannot get protected and private method names!
get_class_vars
Get all current and inherited public properties of the class! But protected and private property names cannot be obtained outside the class!
is_object
Determine whether a variable is an object!
There are many more of this type, so I won’t introduce them one by one. is_integeris_bool is_float|is_double|is_real is_null is_array is_stringis_resource
The above is the detailed content of Related functions of classes and objects in php. For more information, please follow other related articles on the PHP Chinese website!