The PHP Function Get_Parent_Class
One of the coolest things about PHP is that it has a whole lot of built-in functions, which are really just code fragments that you can call directly from your scripts to perform some sort of specific task. But functions are just the tip of the software abstraction iceberg, and hidden beneath that is something even more powerful — classes.
A class is a template from which you can spawn instances, each of which will contain all the properties and methods that you defined in the class. But perhaps more importantly, a class is also capable of extending other classes, and this extension is known as inheritance. Inheritance allows you to define a new class that is based on an existing parent class, and this new child class can inherit all the features of the original parent class, in addition to any new features that the child class added to the parent class.
In PHP, all class properties and methods are public by default – which means that any script can reach inside of an object instance and manipulate the object directly. But if you don't like this intrusion, you can make class methods private or protected, which limits how much access any other script has to your class variables and methods.
This article will introduce the php function get_parent_class, which allows you to retrieve the name of the parent class for a given object or class. It requires no parameters and returns the parent class or false if it's not present.