For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > October 2007 > Update - token_get_all() example









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Update - token_get_all() example
Felipe Pena

2007-10-20, 7:02 pm

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 ) )

?>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com