(PHP 4 >= 4.2.0, PHP 5)php
token_get_all — 将提供的源码按 PHP 标记进行分割,能够用做php源代码的压缩,会按照固定的分解方法,分解php代码成不一样的部分ide
$source
)
token_get_all() 解析提供的 source
源码字符,而后使用 Zend 引擎的语法分析器获取源码中的 PHP 语言的解析器代号ui
解析器代号列表见解析器代号列表, 或者使用 token_name() 翻译获取这个代号的字符串表示.spa
array翻译
1 <?php 2 $tokens = token_get_all('<?php echo; ?>'); /* => array( 3 array(T_OPEN_TAG, '<?php'), 4 array(T_ECHO, 'echo'), 5 ';', 6 array(T_CLOSE_TAG, '?>') ); */ 7 8 /* Note in the following example that the string is parsed as T_INLINE_HTML 9 rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5). 10 This is because no open/close tags were used in the "code" provided. 11 This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */ 12 $tokens = token_get_all('/* comment */'); // => array(array(T_INLINE_HTML, '/* comment */')); 13 ?>