3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class PhpNw15Conference { public function listSpeakers() { return array('James Mallison', 'Some universally hated Ruby developer'); }} /** * Class Controller */ class Controller extends BaseController { /** * @return array */ public function __construct(PhpNw15Conference $conference) { $this->conference = $conference; } public function speakersAction() { $speakers = $this->conference->listSpeakers(); /** Pass to template or CLI runner **/ return $speakers; } } /** Controller Resolver **/ $controller = 'Controller'; // Retrieved from URL + YAML config $action = 'speakersAction'; // Retrieved from URL + Yaml config $params = array(); // Retrieved from GET / POST parameters $reflector = new \ReflectionClass('Controller'); foreach ($reflector->getConstructor()->getParameters() as $parameter) { $className = $parameter->getClass()->getName(); $parameter = new $className; } var_dump((new $controller($parameter))->$action($params));
based on oGEAE
Output for 7.0.0 - 7.2.0
Fatal error: Class 'BaseController' not found in /in/nmGfq on line 8
Process exited with code 255.
Output for 5.4.2 - 5.6.21
Fatal error: Class 'BaseController' not found in /in/nmGfq on line 9
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/nmGfq on line 40
Process exited with code 255.