- token_get_all: documentation ( source)
- var_export: documentation ( source)
- token_name: documentation ( source)
- printf: documentation ( source)
<?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));
}