token_get_all Split given source into PHP tokens &reftitle.description; arraytoken_get_all stringsource intflags0 token_get_all parses the given source string into PHP language tokens using the Zend engine's lexical scanner. For a list of parser tokens, see , or use token_name to translate a token value into its string representation. &reftitle.parameters; source The PHP source to parse. flags Valid flags: TOKEN_PARSE - Recognises the ability to use reserved words in specific contexts. &reftitle.returnvalues; An array of token identifiers. Each individual token identifier is either a single character (i.e.: ;, ., >, !, etc...), or a three element array containing the token index in element 0, the string content of the original token in element 1 and the line number in element 2. &reftitle.changelog; &Version; &Description; 7.0.0 Added the optional flags parameter along with the TOKEN_PARSE flag. 5.2.2 Line numbers are returned in element 2 &reftitle.examples; <function>token_get_all</function> example '); foreach ($tokens as $token) { if (is_array($token)) { echo "Line {$token[2]}: ", token_name($token[0]), " ('{$token[1]}')", PHP_EOL; } } ?> ]]> &example.outputs.similar; ') ]]> <function>token_get_all</function> incorrect usage example ]]> &example.outputs.similar; Note in the previous example that the string is parsed as T_INLINE_HTML rather than the expected T_COMMENT. This is because no open tag was used in the code provided. This would be equivalent to putting a comment outside of the PHP tags in a normal file. <function>token_get_all</function> on a class using a reserved word example ]]> &example.outputs.similar; Without the TOKEN_PARSE flag, the penultimate token (T_STRING) would have been T_PUBLIC. &reftitle.seealso; token_name