Home  >  Article  >  Backend Development  >  Related functions of classes and objects in php

Related functions of classes and objects in php

怪我咯
怪我咯Original
2017-06-28 13:39:231095browse

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 a attribute exists, 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 (static methods 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_integer is_bool is_float|is_double|is_real is_null is_array is_string is_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!

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