3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 ShapeFactory('rectangle');
based on fvGZp
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'RectagleShape' not found in /in/i9SiF:10 Stack trace: #0 /in/i9SiF(49): ShapeFactory->__construct('rectangle') #1 {main} thrown in /in/i9SiF on line 10
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Class 'RectagleShape' not found in /in/i9SiF on line 10
Process exited with code 255.