Home >>
PHP >> What is single inheritance in PHP
What is single inheritance in PHP
Single Inheritance:-Inheritance is the process of get or inherit all properties and methods of one class to another class.A child class derived from a single parent class is called single inheritance.
Example:-
Car is derived from vehicle.
Syntax:-
class base{
//properties
//methods
}
class derived extends base{
//properties
//methods
}
Example:-
class vehicle{
public function name($string){
echo "Parent class".$string;
}
}
class car extends vehicle{
public function name($string){
echo "Child class".$string;
}
}
$vehicle=new vehicle();
$car=new car();
$vehicle->name('of vehicle');
$car->name('of car');
Post Your Comment