- token_get_all: documentation ( source)
<?php
$code = '<?php
function blah($num) {
if ($num) {
return $num + 1;
}
return 0;
}
';
$tokens = token_get_all($code);
foreach ($tokens as $token) {
echo token_get_name($token) . "\n";
}