3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Car { abstract function objectify(); } class BMW extends Car { public function objectify() { return "I'm a BMW"; } } class Honda extends Car { public function objectify() { return "I'm a Honda"; } } class Tesla extends Car { public function objectify() { return "I'm a Tesla"; } } $carTypes = array("Germany" => "BMW", "Japan" => "Honda", "America" => "Tesla"); $country = "Germany"; //replace this with actual user input, in your version $car = new $carTypes[$country](); echo $car->objectify();
Output for git.master_jit, git.master, rfc.property-hooks
I'm a BMW

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:
31.88 ms | 405 KiB | 5 Q