Posted inphp / Laravel

What is function overriding in php?

Today, We want to share with you function overriding in php.In this post we will show you php override function with different parameters, hear for overloading and overriding in php in hindi we will give you demo and example for implement.In this post, we will learn about Polymorphism In PHP Object-Oriented Programming with an example.

Overloading and Overriding in PHP with Examples

simple defination Overriding is only pertinent to derived classes, where the main parent class has defined a some method as well as the derived some class wishes to override that some method.

Function Overloading:

area(2)); 
echo "\n"; 
	 
echo ($s->area(4, 2)); 
?> 

Function Overriding:

getData(); 

$c->getData(); 
?> 

An example of overriding:

getData()); //"Data"
echo($list->getData()); //"List"
?>

PHP overriding methods

here you can learn to Function overriding is used when a class has more methods as well as more derived class wants same functions or methods with different types of the behavior. Therefor, using overriding you can best way to updating the behavior of parent class.

as well as Function overriding can be step by step useful by extending a class as well as rewriting a function which existed in the more parent class.

class Akar {
    function myAkar() {
        return "Akar";
    }
}
class Chorash extends Akar {
    function myAkar() {
        return "Chorash";
        }
}
$shape = new Akar;
$square = new Chorash;
echo($shape->myAkar()); //"Akar"
echo($square->myChorash()); //"Chorash"
?>

I hope you get an idea about function overriding in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype