PHP OOP inheritance

Inheritance is an oops concepts using inheritance we can reuse the properties on other class.
or we can say it is a mechanism by which we can inherit one class propeties to other class.

Example
class Account{
	public $name, $age;
	public function __construct($name="Guest", $age=0){
		$this->name = $name;
		$this->age = $age;
	}
	public function display(){
		echo "
		Name: $this->name <br>
		Age: $this->age <hr>
		";
	}
}

class Employee extends Account{

}

$emp = new Employee("Ankit", 20);
$emp->display();
© 2016 - 2022, All Rights are Reserved.