3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function publicFN() { echo "\npublic call\n"; } protected function protectedFN() { echo "\nprotected call\n"; } private function privateFN() { echo "\nprivate call\n"; } } $foo = new Foo(); foreach (['publicFN', 'protectedFN', 'privateFN'] as $fn) { $callable = [$foo, $fn]; if (method_exists($foo, $fn)) { printf("%s::%s() exists\n", get_class($foo), $fn); } if (method_exists($foo, $fn)) { $callable(); } }
Output for git.master_jit, git.master, rfc.property-hooks
Foo::publicFN() exists public call Foo::protectedFN() exists Fatal error: Uncaught Error: Call to protected method Foo::protectedFN() from global scope in /in/eXkna:19 Stack trace: #0 {main} thrown in /in/eXkna on line 19
Process exited with code 255.

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