3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_class_name($class) { if (is_object($class)) { return get_class_name(get_class($class)); } else if (is_string($class)) { if (strpos('\\', $class) !== false) { return substr(strrchr($class, '\\'), 1); } return $class; } return false; } abstract class Visitor { public final function __call(string $method, array $args) { if ($method === 'visit') { $method .= get_class_name(static::class); die($method); 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
visitFooVisitor

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