3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ShapeFactory { public function __construct($type) { $shape = null; switch ($type){ case 'rectangle': $shape = new RectangleShape; break; case 'square': $shape = new SquareShape; break; default: return 'No such file'; } return $shape->render(); } } interface Shape { public function render(); } class SquareShape implements Shape { public $name = 'square'; public function render() { return $this->name; } } class RectangleShape implements Shape { public $name = 'rectangle'; public function render() { echo $this->name; return $this->name; } } $test = new ShapeFactory('rectangle'); echo $test;
Output for git.master, git.master_jit, rfc.property-hooks
rectangle Fatal error: Uncaught Error: Object of class ShapeFactory could not be converted to string in /in/XvbAP:51 Stack trace: #0 {main} thrown in /in/XvbAP on line 51
Process exited with code 255.

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:
52.9 ms | 401 KiB | 8 Q