Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP get_parent_class() Function.
The built-in PHP get_parent_class() function gets the parent class name for the object or class.
The built-in PHP get_parent_class() function gets the parent class name for the object or class.
Syntax
Following below is the syntax to use this function -
get_parent_class ( $object );
Parameter Details
Sr.No | Parameter & Description |
---|---|
1 | object(Required) The tested object or class name. |
Return Value
This built-in PHP function returns an array of the names of the declared classes in the current script.
Example
Try out the below example -
<?php class f1 { function f1() { // implements some logic } } class child extends f1 { function child() { echo "I'm " , get_parent_class($this) , "'s son \n"; } } class child2 extends f1 { function child2() { echo "I'm " , get_parent_class('child2') , "'s son too \n"; } } $foo = new child(); $bar = new child2(); ?>
Output
When the above code is executed, it will produce the following result -
I'm f1's son I'm f1's son too
Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP interface_exists() Function.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.