<?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.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14, 8.4.1
- 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.0
- T_OPEN_TAG: '<?php '
T_PRINT: 'print'
T_WHITESPACE: ' '
(literal): '"'
T_VARIABLE: '$array'
(literal): '['
T_STRING: '\'a\''
(literal): ']'
(literal): '"'
(literal): ';'
preferences:
69.99 ms | 408 KiB | 5 Q