downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
Last updated: Mon, 16 Jul 2012


(PHP 4 >= 4.2.0, PHP 5)

token_get_all -- Split given source into PHP tokens


array token_get_all ( string source )

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 附录 P, or use token_name() to translate a token value into its string representation.



The PHP source to parse.


An array of token identifiers. Each individual token identifier is either a single character (i.e.: ;, ., >, !, etc...), or a two element array containing the token index in element 0, and the string content of the original token in element 1.

例子 1. token_get_all() examples

= token_get_all('<?php echo; ?>'); /* => array(
                                                 array(T_OPEN_TAG, '<?php'),
                                                 array(T_ECHO, 'echo'),
                                                 array(T_CLOSE_TAG, '?>') ); */

/* Note in the following example that the string is parsed as T_INLINE_HTML
   rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
   This is because no open/close tags were used in the "code" provided.
   This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */
$tokens = token_get_all('/* comment */'); // => array(array(T_INLINE_HTML, '/* comment */'));

 Last updated: Mon, 16 Jul 2012
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at:
Last updated: Thu Jul 7 19:13:47 2005 CST