3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = '<?php print "$array[\'a\']";'; foreach (token_get_all($str) as $t) { if (is_array($t)) { $n = token_name($t[0]); $v = $t[1]; } else { $n = "(literal)"; $v = $t; } printf("%25s: %s\n", $n, var_export($v,TRUE)); }
Output for 5.2.3 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.1.7
T_OPEN_TAG: '<?php ' T_PRINT: 'print' T_WHITESPACE: ' ' (literal): '"' T_VARIABLE: '$array' (literal): '[' T_ENCAPSED_AND_WHITESPACE: '' T_ENCAPSED_AND_WHITESPACE: '\'a\']' (literal): '"' (literal): ';'
Output for 4.3.2 - 5.2.2
T_OPEN_TAG: '<?php ' T_PRINT: 'print' T_WHITESPACE: ' ' (literal): '"' T_VARIABLE: '$array' (literal): '[' T_ENCAPSED_AND_WHITESPACE: '\'' T_STRING: 'a' T_ENCAPSED_AND_WHITESPACE: '\'' (literal): ']' (literal): '"' (literal): ';'
Output for 4.3.0 - 4.3.1
T_OPEN_TAG: '<?php ' T_PRINT: 'print' T_WHITESPACE: ' ' (literal): '"' T_VARIABLE: '$array' (literal): '[' T_STRING: '\'a\'' (literal): ']' (literal): '"' (literal): ';'