3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ShapeFactory { public function __construct($type) { $shape = null; switch ($type){ case 'rectangle': $shape = new RectagleShape; break; case 'square': $shape = new SquareShape; break; default: return 'No such file'; } return $shape->render(); } } interface Shape { public function render(); } class Square implements Shape { public $name = 'square'; public function render() { return $this->name; } } class Rectangle implements Shape { public $name = 'rectangle'; public function render() { return $this->name; } } $test = new Factory('rectangle');
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Class "Factory" not found in /in/fvGZp:49 Stack trace: #0 {main} thrown in /in/fvGZp on line 49
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:
57.96 ms | 401 KiB | 8 Q