- token_get_all: documentation ( source)
- token_name: documentation ( source)
<?php
$code = "<?php
namespace Test;
class TestClass {
}
";
$tokens = token_get_all($code);
$count = count($tokens);
for($i = 0; $i < $count; $i++) {
echo token_name($tokens[$i][0]);
echo "|";
echo $tokens[$i][0];
echo "|";
echo $tokens[$i][1];
echo "|";
echo $tokens[$i][2];
echo "\n";
}