Javatpoint Logo
Javatpoint Logo

Some Helpful Functions in PHP to get the Information About Class and Object

1. get_class: By using this, we can get the class name of an object.

Example 1

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

2. get_class_vars: It is used to get all variables of a class as Array elements.

Example 2

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

3. get_class_methods: To get the all methods of a class as an array.

Example 3

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

4. get_declare_classes: To get the all declare classes in current script along with predefined classes.

Example 4

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

5. get_object_vars: To get all variables of an object as an array.

Example 5

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

6. class_exists: To check whether the specified class is existed or not.

Example 6

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

7. is_subclass_of: By using this function we can check whether the 1st class is subclass of 2nd class or not.

Example 7

Output:

Some Helpful Functions in PHP to get the Information About Class and Object

8. method_exists: By using this function we can check whether the class method is existed or not.

Example 8

Output:

Some Helpful Functions in PHP to get the Information About Class and Object
Next Topic




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA