(PHP 4 >= 4.2.0, PHP 5, PHP 7)
token_get_all — 锟斤拷锟结供锟斤拷源锟诫按 PHP 锟斤拷墙锟斤拷蟹指锟�
$source
) : array
token_get_all() 锟斤拷锟斤拷锟结供锟斤拷 source
源锟斤拷锟街凤拷锟斤拷然锟斤拷使锟斤拷 Zend 锟斤拷锟斤拷锟斤拷锓拷锟斤拷锟斤拷锟斤拷锟饺≡达拷锟斤拷械锟� PHP 锟斤拷锟皆的斤拷锟斤拷锟斤拷锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫憋拷锟�锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫憋拷, 锟斤拷锟斤拷使锟斤拷 token_name() 锟斤拷锟斤拷锟饺★拷锟斤拷锟斤拷锟脚碉拷锟街凤拷锟斤拷锟斤拷示.
source
锟斤拷要锟斤拷锟斤拷锟斤拷 PHP 源锟斤拷.
An array of token identifiers. Each individual token identifier is either a single character (i.e.: ;, ., 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.
Example #1 token_get_all() examples
<?php
$tokens = 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 */'));
?>
锟芥本 | 说锟斤拷 |
---|---|
5.2.2 | Line numbers are returned in element 2 |