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 SquareShape implements Shape { public $name = 'square'; public function render() { return $this->name; } } class RectangleShape implements Shape { public $name = 'rectangle'; public function render() { return $this->name; } } $test = new ShapeFactory('rectangle');
based on i9SiF
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'RectagleShape' not found in /in/4EBIM:10 Stack trace: #0 /in/4EBIM(49): ShapeFactory->__construct('rectangle') #1 {main} thrown in /in/4EBIM on line 10
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Class 'RectagleShape' not found in /in/4EBIM on line 10
Process exited with code 255.