Method Overriding

If child class has the same method and parameter as declared in the parent class, it is known as method overriding.

Note:-(i) Method overriding is used for runtime polymorphism.
(ii) static method of the class can not be override.

Example:-
In below example, All company give to a fresher package according to company rule. TCS gives 3.2 lakh per annum and Oracle gives 4.2 Lakh Package per annum and some small company does not give money to employee.
(i) fresherPackage method of TCS class override the method fresherPackage of company class.
(ii) fresherPackage method of Oracle class override the method fresherPackage of company class.

<?php
class company {
	public function fresherPackage() {
		echo 0;
	}
}
class TCS extends company{
	public function fresherPackage() {
		echo 'TCS provide 3.2 Lakh per annum.';
	}
}
class Oracle extends company{
	public function fresherPackage() {
		echo 'Oracle provide 4.2 Lakh per annum.';
	}
}
$tcs_Obj=new TCS;
$tcs_Obj->fresherPackage();

$oracle_Obj=new Oracle;
$oracle_Obj->fresherPackage();
?>
Output:- TCS provide 3.2 Lakh per annum.
Oracle provide 4.2 Lakh per annum.