3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class App { public static $classes = array(); public static function register($name, Callable $generator) { static::classes[$name] = $generator; } public static function make($name) { if (!isset(static::classes[$name])) { throw new Exception('Invalid class name'); } return static::classes[$name](); } } // Internal declaration class Foo { public static function bar() { return 'static'; } } App::register('foo', function() { return new Foo; }); // Internal Usage class SomeController { public function view() { echo App::make('foo')->bar(); } } // Some extending application class MyFoo extends Foo { public static function bar() { return 'can\'t make internal methods use this.'; } } App::register('foo', function() { return new MyFoo; }); $c = new SomeController; $c->view();
Output for 5.3.0 - 5.4.27
Parse error: syntax error, unexpected '[' in /in/gFjIr on line 10
Process exited with code 255.