3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Controller { public function testAction() { } public static function staticAction() { } public function __call($method, $arguments) { } } $calls = array( array('Controller', 'testAction'), array('Controller', 'staticAction'), array('Controller', 'fooAction'), array(new Controller, 'testAction'), array(new Controller, 'staticAction'), array(new Controller, 'fooAction'), ); foreach($calls as $controller) { $data = array(); try { $r = new ReflectionMethod($controller[0], $controller[1]); $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getStartLine(), ); } catch (ReflectionException $re) { if (is_callable($controller) || method_exists($controller[0], '__call')) { $r = new ReflectionClass($controller[0]); // using __call magic $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getMethod('__call')->getStartLine(), ); } } var_dump($data); }
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(10) "testAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(5) } } array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(12) "staticAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(10) } } array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(9) "fooAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(15) } } array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(10) "testAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(5) } } array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(12) "staticAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(10) } } array(1) { ["controller"]=> array(4) { ["class"]=> string(10) "Controller" ["method"]=> string(9) "fooAction" ["file"]=> string(9) "/in/tmC0X" ["line"]=> int(15) } }

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:
48.95 ms | 403 KiB | 8 Q