function.token-get-all.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 122 行
HTML
122 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Split given source into PHP tokens</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.tokenizer.html">Tokenizer Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.token-name.html">token_name</a></div> <div class="up"><a href="ref.tokenizer.html">Tokenizer Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.token-get-all" class="refentry"> <div class="refnamediv"> <h1 class="refname">token_get_all</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">token_get_all</span> — <span class="dc-title">Split given source into PHP tokens</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>token_get_all</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$source</tt></span> )</div> <p class="para rdfs-comment"> <b>token_get_all()</b> parses the given <i><tt class="parameter">source</tt></i> string into PHP language tokens using the Zend engine's lexical scanner. </p> <p class="para"> For a list of parser tokens, see <a href="tokens.html" class="xref">List of Parser Tokens</a>, or use <a href="function.token-name.html" class="function">token_name()</a> to translate a token value into its string representation. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">source</tt></i></span> <dd> <p class="para"> The PHP source to parse. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> An array of token identifiers. Each individual token identifier is either a single character (i.e.: <i>;</i>, <i>.</i>, <i>></i>, <i>!</i>, 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. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>token_get_all()</b> examples</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$tokens </span><span style="color: #007700">= </span><span style="color: #0000BB">token_get_all</span><span style="color: #007700">(</span><span style="color: #DD0000">'<?php echo; ?>'</span><span style="color: #007700">); </span><span style="color: #FF8000">/* => array(<br /> array(T_OPEN_TAG, '<?php'), <br /> array(T_ECHO, 'echo'),<br /> ';',<br /> array(T_CLOSE_TAG, '?>') ); */<br /><br />/* Note in the following example that the string is parsed as T_INLINE_HTML<br /> rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).<br /> This is because no open/close tags were used in the "code" provided.<br /> This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */<br /></span><span style="color: #0000BB">$tokens </span><span style="color: #007700">= </span><span style="color: #0000BB">token_get_all</span><span style="color: #007700">(</span><span style="color: #DD0000">'/* comment */'</span><span style="color: #007700">); </span><span style="color: #FF8000">// => array(array(T_INLINE_HTML, '/* comment */'));<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.2.2</td> <td colspan="1" rowspan="1" align="left">Line numbers are returned in element 2 </td> </tr> </tbody> </colgroup> </table> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.tokenizer.html">Tokenizer Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.token-name.html">token_name</a></div> <div class="up"><a href="ref.tokenizer.html">Tokenizer Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?