3v4l.org

run code in 300+ PHP versions simultaneously
<?php // parent class class Vehicle { // private property name private $name; // public function start public function start() { echo $this->name. " - Engine start...<br/>"; } // public function stop public function stop() { echo $this->name. " - Engine stop...<br/>"; } } // child class class Car extends Vehicle { public function drive() { // accessing name variable of Car class echo "I am " . $this->name . "<br/>"; echo "Lets go on a drive..."; } } $car = new Car(); $car->name = "Mercedes benz"; var_dump($car);

preferences:
49.35 ms | 407 KiB | 5 Q