3v4l.org

run code in 300+ PHP versions simultaneously
<?php class App { public $classes = array(); public function register($name, Callable $generator) { $this->classes[$name] = $generator; } public function make($name) { if (!isset($this->classes[$name])) { throw new Exception('Invalid class name'); } return $this->classes[$name](); } } $app = new App; // Internal declaration class Foo { public static function bar() { return 'static'; } } $app->register('foo', function() { return new Foo; }); // Internal Usage class SomeController { public function view() { global $app; 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 git.master, git.master_jit, rfc.property-hooks
can't make internal methods use this.

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:
43.82 ms | 401 KiB | 8 Q