3v4l.org

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