3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Car { protected $speed = 0; protected $people = 0; public function onboardPerson() { $this->people++; } public function accelerate() { $this->speed++; } } class Taxi extends Car { protected $fare; public function setFare($fare) { $this->fare = $fare; } } $taxi = new Taxi(); // Replace instances of type Car (T) with subtype Taxi (S) $taxi->onboardPerson(); $taxi->accelerate(); var_dump($taxi);

preferences:
30.74 ms | 402 KiB | 5 Q