Function overloading and overriding is the OOPs feature in PHP. In function overloading, more than one function can have same method signature but different number of arguments. But in case of function overriding, more than one functions will have same method signature and number of arguments.
Function Overloading: Function overloading contains same function name and that function preforms different task according to number of arguments. For example, find the area of certain shapes where radius are given then it should return area of circle if height and width are given then it should give area of rectangle and others. Like other OOP languages function overloading can not be done by native approach. In PHP function overloading is done with the help of magic function __call(). This function takes function name and arguments.
Function Overriding: Function overriding is same as other OOPs programming languages. In function overriding, both parent and child classes should have same function name with and number of arguments. It is used to replace parent method in child class. The purpose of overriding is to change the behavior of parent class method. The two methods with the same name and same parameter is called overriding.
- Method Overriding in Scala
- Overloading in PHP
- C++ Program to concatenate two strings using Operator Overloading
- Types of Operator Overloading in C++
- C# | Constructor Overloading
- C# | Overloading of Indexers
- Operator Overloading in Ruby
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- Difference between isset() and array_key_exists() Function in PHP
- Why to check both isset() and !empty() function in PHP ?
- What is the difference between is_a() function and instanceof in PHP?
- What is the difference between a language construct and a “built-in” function in PHP ?
- How to use php serialize() and unserialize() Function
- Difference and Similarities between PHP and C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.