class ToyotaCorolla {
public $color; // <-------- Properties
public $doors; // <----/
public function honk() { // <---- Method
print "beep, beep!";
}
}
$myCar = new ToyotaCorolla(); // Create a new instance of our class
$myCar->honk(); // "beep, beep"
Uses the properties and methods of the existing class but now we can override or add to them.
class DamagedToyotaCorolla extends ToyotaCorolla { // Inherit everything
// Already have the $color and $doors properties
public function honk() { // Override the honk method
print "beep, clunk";
}
{
$myCar = new DamagedToyotaCorolla(); // Create a new instance of our class
$myCar->honk(); // "beep, clunk"