Token¶
A PHP token is the smallest unit of code that has meaning in the language. When the source code is parsed, it is broken down into tokens before being executed. Tokens include keywords, variables, constants, operators, and other syntactic elements.
Tokens of a specific code are accessible via the function token_get_all()
.
<?php
print_r(token_get_all("<?php phpinfo()"));
/**
Array
(
[0] => Array
(
[0] => 389
[1] => <?php
[2] => 1
)
[1] => Array
(
[0] => 262
[1] => phpinfo
[2] => 1
)
[2] => (
[3] => )
)
*/
?>
See also https://www.php.net/token_get_all, https://www.php.net/manual/en/tokens.php