3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; private $baz; protected function getBar() { return __METHOD__; } private function getBaz() { return __METHOD__; } public function __call($methodName, $args) { if (!method_exists($this, $methodName)) { return 'some wise behavior'; } return 'Magic! '.$this->$methodName(...$args); } } $foo = new Foo(); var_dump(method_exists($foo, '__call')); var_dump(method_exists($foo, 'bar')); var_dump(method_exists($foo, 'baz')); var_dump($foo->__call('baz', [])); var_dump($foo->baz()); var_dump($foo->__call('nonexistent', []));
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) bool(false) bool(false) string(18) "some wise behavior" string(18) "some wise behavior" string(18) "some wise behavior"

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:
24.02 ms | 405 KiB | 5 Q