3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Visitor { public final function __call(string $method, array $args) { if ($method === 'visit') { $class = substr(strrchr(static::class, '\\'), 1); $method .= $class; die(static::class); if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $args); } } throw new Exception('Unknown method ' . $method); } } interface Visitable { public function accept(Visitor $v); } class FooVisitor extends Visitor { public function visitFoo(Foo $foo) { print 'visit Foo' . PHP_EOL; } } class Foo implements Visitable { public function accept(Visitor $v) { $v->visit($this); } } $fv = new FooVisitor(); $f = new Foo(); $f->accept($fv);
Output for git.master, git.master_jit, rfc.property-hooks
FooVisitor

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