2002-05-02 13:22:42 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-01-07 23:15:48 +00:00
|
|
|
<!-- $Revision: 1.7 $ -->
|
2002-05-02 13:22:42 +00:00
|
|
|
<refentry id="function.token-get-all">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>token_get_all</refname>
|
2003-02-06 09:38:26 +00:00
|
|
|
<refpurpose>Split given source into PHP tokens</refpurpose>
|
2002-05-02 13:22:42 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
2003-02-06 09:38:26 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>array</type><methodname>token_get_all</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>source</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2003-08-20 20:46:54 +00:00
|
|
|
<simpara>
|
2003-02-06 09:38:26 +00:00
|
|
|
<function>token_get_all</function> parses the given <parameter>source</parameter>
|
2003-08-20 20:46:54 +00:00
|
|
|
string into PHP language tokens using the Zend engine's lexical scanner.
|
|
|
|
The function returns an array of token identifiers. Each individual token
|
|
|
|
identifier is either a single character (i.e.: <constant>;</constant>,
|
|
|
|
<constant>.</constant>, <constant>></constant>, <constant>!</constant>, etc...),
|
|
|
|
or a two element array containing the token index in element 0, and the string
|
|
|
|
content of the original token in element 1.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
For a list of parser tokens, see <xref linkend="tokens"/>, or use
|
|
|
|
<function>token_name</function> to translate a token value into its string
|
|
|
|
representation.
|
|
|
|
</simpara>
|
2003-02-06 15:07:51 +00:00
|
|
|
<example>
|
2003-08-20 20:46:54 +00:00
|
|
|
<title><function>token_get_all</function> examples</title>
|
2003-02-06 09:38:26 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-01-07 23:15:48 +00:00
|
|
|
$tokens = token_get_all('<?php'); // => array(array(T_OPEN_TAG, '<?'));
|
|
|
|
$tokens = token_get_all('<?php echo; ?>'); /* => array(
|
|
|
|
array(T_OPEN_TAG, '<?php'),
|
2003-08-20 20:46:54 +00:00
|
|
|
array(T_ECHO, 'echo'),
|
|
|
|
';',
|
|
|
|
array(T_CLOSE_TAG, '?>') ); */
|
|
|
|
|
|
|
|
/* Note in the following example that the string is parsed as T_INLINE_HTML
|
2004-01-07 23:15:48 +00:00
|
|
|
rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
|
2003-08-20 20:46:54 +00:00
|
|
|
This is because no open/close tags were used in the "code" provided.
|
2004-01-07 23:15:48 +00:00
|
|
|
This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */
|
2003-08-20 20:46:54 +00:00
|
|
|
$tokens = token_get_all('/* comment */'); // => array(array(T_INLINE_HTML, '/* comment */'));
|
2003-02-06 09:38:26 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
2003-02-06 15:07:51 +00:00
|
|
|
</example>
|
2002-05-02 13:22:42 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|