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 token_get_all and List of Parser Tokens.
Related : Abstract Syntactic Tree (AST), Curly Brackets, Single Sign On (SSO), Tokenizer, Whitespace, JSON Web Token (JWT), OAuth