3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = '<?php public function enum($value, ...$items) {}'; $tokens = token_get_all($string); foreach ($tokens as $token) { if (is_array($token) === true) { $name = token_name($token[0]); echo "TOKEN $name FOUND: ".$token[1]."\n"; } else { echo "NON ARRAY TOKEN FOUND: ".$token."\n"; } }
based on Bev9Y
Output for 5.6.0 - 7.1.0
TOKEN T_OPEN_TAG FOUND: <?php TOKEN T_PUBLIC FOUND: public TOKEN T_WHITESPACE FOUND: TOKEN T_FUNCTION FOUND: function TOKEN T_WHITESPACE FOUND: TOKEN T_STRING FOUND: enum NON ARRAY TOKEN FOUND: ( TOKEN T_VARIABLE FOUND: $value NON ARRAY TOKEN FOUND: , TOKEN T_WHITESPACE FOUND: TOKEN T_ELLIPSIS FOUND: ... TOKEN T_VARIABLE FOUND: $items NON ARRAY TOKEN FOUND: ) TOKEN T_WHITESPACE FOUND: NON ARRAY TOKEN FOUND: { NON ARRAY TOKEN FOUND: }
Output for 5.0.0 - 5.5.38
TOKEN T_OPEN_TAG FOUND: <?php TOKEN T_PUBLIC FOUND: public TOKEN T_WHITESPACE FOUND: TOKEN T_FUNCTION FOUND: function TOKEN T_WHITESPACE FOUND: TOKEN T_STRING FOUND: enum NON ARRAY TOKEN FOUND: ( TOKEN T_VARIABLE FOUND: $value NON ARRAY TOKEN FOUND: , TOKEN T_WHITESPACE FOUND: NON ARRAY TOKEN FOUND: . NON ARRAY TOKEN FOUND: . NON ARRAY TOKEN FOUND: . TOKEN T_VARIABLE FOUND: $items NON ARRAY TOKEN FOUND: ) TOKEN T_WHITESPACE FOUND: NON ARRAY TOKEN FOUND: { NON ARRAY TOKEN FOUND: }
Output for 4.3.0 - 4.4.9
TOKEN T_OPEN_TAG FOUND: <?php TOKEN T_STRING FOUND: public TOKEN T_WHITESPACE FOUND: TOKEN T_FUNCTION FOUND: function TOKEN T_WHITESPACE FOUND: TOKEN T_STRING FOUND: enum NON ARRAY TOKEN FOUND: ( TOKEN T_VARIABLE FOUND: $value NON ARRAY TOKEN FOUND: , TOKEN T_WHITESPACE FOUND: NON ARRAY TOKEN FOUND: . NON ARRAY TOKEN FOUND: . NON ARRAY TOKEN FOUND: . TOKEN T_VARIABLE FOUND: $items NON ARRAY TOKEN FOUND: ) TOKEN T_WHITESPACE FOUND: NON ARRAY TOKEN FOUND: { NON ARRAY TOKEN FOUND: }