3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $code = '<?php $a = $a + $b; function extractURL($url) { if (preg_match(\'#http://www.google.com/?$#i\', $url, $match)) { return $match[1]; } return null; } '; $tokens = token_get_all($code); foreach ($tokens as $token) { if (is_string($token)) { print "[(string)] " . $token . "\r\n"; } else { print "[" . token_name($token[0]) . "] " . $token[1] . "\r\n"; } }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
[T_OPEN_TAG] <?php [T_VARIABLE] $a [T_WHITESPACE] [(string)] = [T_WHITESPACE] [T_VARIABLE] $a [T_WHITESPACE] [(string)] + [T_WHITESPACE] [T_VARIABLE] $b [(string)] ; [T_WHITESPACE] [T_FUNCTION] function [T_WHITESPACE] [T_STRING] extractURL [(string)] ( [T_VARIABLE] $url [(string)] ) [T_WHITESPACE] [(string)] { [T_WHITESPACE] [T_IF] if [T_WHITESPACE] [(string)] ( [T_STRING] preg_match [(string)] ( [T_CONSTANT_ENCAPSED_STRING] '#http://www.google.com/?$#i' [(string)] , [T_WHITESPACE] [T_VARIABLE] $url [(string)] , [T_WHITESPACE] [T_VARIABLE] $match [(string)] ) [(string)] ) [T_WHITESPACE] [(string)] { [T_WHITESPACE] [T_RETURN] return [T_WHITESPACE] [T_VARIABLE] $match [(string)] [ [T_LNUMBER] 1 [(string)] ] [(string)] ; [T_WHITESPACE] [(string)] } [T_WHITESPACE] [T_RETURN] return [T_WHITESPACE] [T_STRING] null [(string)] ; [T_WHITESPACE] [(string)] } [T_WHITESPACE]