class User { public $name; public $email; public function set_name($name) { $this->name = $name; } public function set_email($email) { $this->email = $email; } public function get_name() { return $this->name; } public function get_email() { return $this->email; } }
class Vehicle { protected $brand; protected $model; public function __construct($brand, $model) { $this->brand = $brand; $this->model = $model; } public function getInfo() { return $this->brand .' '. $this->model; } } class Car extends Vehicle { protected $color; public function __construct($brand, $model, $color) { parent::__construct($brand, $model); $this->color = $color; } public function getInfo() { return parent::getInfo().' ('.$this->color.')'; } }This example demonstrates the use of inheritance. The Vehicle class defines properties and a method to return vehicle information. The Car class extends Vehicle and adds a color property and its own getInfo method which calls the parent class getInfo method. Package library: No specific package library used.