3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Vehicle { protected static $wheels = 4; public function wheels() { return get_class($this) . " has " . static::$wheels . " wheels\n"; } } class Bike extends Vehicle { protected static $wheels = 2; } class Car extends Vehicle { protected static $wheels = 4; } class Car_With_Trailer extends Car { protected static $wheels = 6; } $bike = new Bike(); $car = new Car(); $car_with_trailer = new Car_With_Trailer(); print $car->wheels(); print $bike->wheels(); print $car_with_trailer->wheels();
Output for git.master, git.master_jit, rfc.property-hooks
Car has 4 wheels Bike has 2 wheels Car_With_Trailer has 6 wheels

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.28 ms | 405 KiB | 5 Q