Difference between Function Overloading and Overriding in PHP

When a function having same name with different arguments it is called Function Overloading.
Example:

class calculate{
function add($a,$b){
return $a+$b;
}
function add($a,$b,$c){
return $a+$b+$c;
}
}

when we have two classes and derived class also have the same function as declared and define in its base class with same name and same signature it is known as Function Overriding.

Example:

class Parent{
function funOverriding() {
return “Parent”;
}
}
class Child extends Parent{
function funOverriding() {
return “Child”;
}
}
$parent= new Parent;
$child= new Child;
echo($parent->funOverriding()); //”It will refer to parent class function”
echo($child->funOverriding()); // “It will refer to child class function”

you can see in example that we can call particular function by pointing them with the object of that class.

  1. Amazing! Its in fact amazing post, I have got much
    clear idea on the topic of from this article.

  2. Link exchange is nothing else except it is just placing the other person’s web site link on your page at proper place and other person will also
    do same in support of you.

  3. Hey There. I found your blog using msn. This is an extremely well written article.
    I’ll make sure to bookmark it and come back to read more
    of your useful info. Thanks for the post. I will definitely return.

  4. Hi there, I discovered your website by means of
    Google at the same time as searching for a related
    matter, your web site came up, it looks great.
    I have bookmarked it in my google bookmarks.

    Hi there, just changed into alert to your weblog thru Google, and located that it is
    really informative. I am going to be careful for brussels. I will be grateful in case you proceed this in future.

    A lot of people will probably be benefited from your writing.
    Cheers!

*