3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test; $function = function () { return $a + $b . "Hello {$c} World!"; }; // Reflect the closure and fetch relevant properties $reflection = new \ReflectionFunction($function); $fileName = $reflection->getFileName(); $startLine = $reflection->getStartLine(); $endLine = $reflection->getEndLine(); // Slice out the lines $lines = array_slice(file($fileName), $startLine - 1, ($endLine - $startLine) + 1); $code = sprintf('<?php %s ; ?>', implode($lines)); // Tokenize and filter T_WHITESPACE $tokens = array_filter(token_get_all($code), function ($token) { return !(is_array($token) && $token[0] === T_WHITESPACE); }); // Dump for shits and giggles foreach ($tokens as $token) { echo PHP_EOL; if (is_array($token)) { echo str_pad(token_name($token[0]), 30, '.') . trim($token[1]); continue; } echo str_pad('SYMBOL', 30, '.') . $token; }
Output for git.master, git.master_jit, rfc.property-hooks
T_OPEN_TAG....................<?php T_VARIABLE....................$function SYMBOL........................= T_FUNCTION....................function SYMBOL........................( SYMBOL........................) SYMBOL........................{ T_RETURN......................return T_VARIABLE....................$a SYMBOL........................+ T_VARIABLE....................$b SYMBOL......................... SYMBOL........................" T_ENCAPSED_AND_WHITESPACE.....Hello T_CURLY_OPEN..................{ T_VARIABLE....................$c SYMBOL........................} T_ENCAPSED_AND_WHITESPACE.....World! SYMBOL........................" SYMBOL........................; SYMBOL........................} SYMBOL........................; SYMBOL........................; T_CLOSE_TAG...................?>

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.64 ms | 403 KiB | 8 Q