3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = new ReflectionClass(A::class); extractMethodBody($re->getMethod('test')); /** * @param \ReflectionMethod $method * @return string */ function extractMethodBody(\ReflectionMethod $method) { $startLine = $method->getStartLine(); $endLine = $method->getEndLine() + 1; $resource = fopen($method->getFileName(), 'r'); $currentLine = 0; while (!feof($resource) && ++$currentLine < $startLine) { fgets($resource, 1024); } $buffer = ''; while (!feof($resource) && ++$currentLine <= $endLine) { $buffer .= fgets($resource, 1024); } preg_match(sprintf('/(?:public|protected|private|final|abstract|static)*?' . '\s+function\s+%s\([^\)]*\)\s*(?:\{(?:[^{}]*|(?R))*\})/sm', preg_quote($method->getName())), $buffer, $matches ); return $matches[0]; } class A { public function test(stdClass $b) { return $b; } }
Output for git.master, git.master_jit, rfc.property-hooks

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