Update - token_get_all() example
| From: | Felipe Pena | Date: | Sat, 20 Oct 2007 18:41:29 +0000 |
| Subject: | Update - token_get_all() example | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969378245@lists.php.net to get a copy of this message | ||
Update example according to PHP 5.2.2 (Line numbers are returned in
element 2):
<?php
$tokens = token_get_all('<?php echo; ?>');
/* array ( array ( 0 => 367, 1 => '<?php ', 2 => 1 ),
array ( 0 => 316, 1 => 'echo', 2 => 1 ),
';',
array ( 0 => 370, 1 => ' ', 2 => 1 ),
array ( 0 => 369, 1 => '?>', 2 => 1 ) ) */
/* 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 ( 0 => 311, 1 => '/* comment */', 2 => 1 ) )
?>