|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-19 17:48 UTC] steemann at globalpark dot de
Description:
------------
Don't know if it's a tokenizer issue or something else:
I just wanted to check out the token_get_all() function.
I tried the test code from the manual page (see code
below). I am using token_get_all() with a constant input.
Unfortunately, on my box, the result for the test code is
varying, i. e. tokening a constant string has two
different results. I found this out it by simple hitting
reload in the browser multiple times. I've put both
results I've gotten in the "Actual result" textarea. The
possibility for each result seems to be about 50%.
Environment:
Configure Command => './configure'
'--with-apxs=/opt/pdp/apache/bin/apxs'
'--prefix=/opt/pdp/php' '--with-mysql=/opt/pdp/mysql/'
'--with-config-file-path=/opt/pdp/'
'--with-iconv=/opt/pdp/iconv/'
'--with-imagick=/opt/pdp/ImageMagick/' '--with-zlib'
'--with-gd' '--with-freetype-dir=/usr'
'--enable-gd-native-ttf' '--enable-gd-imgstrttf'
'--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-dom'
'--with-dom-xslt' '--with-dom-exslt' '--enable-sysvsem'
'--enable-sysvshm' '--disable-debug' '--enable-sockets'
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 20021010
Debug Build => no
Thread Safety => disabled
Maybe my box is f**ked up??
Reproduce code:
---------------
$data="<?php ob_start(); ?>";
foreach(token_get_all($data) as $c)
{
if(is_array($c))
{
print(token_name($c[0]) . ": '".htmlentities($c[1])."'\n");
}
else
{
print("$c\n");
}
}
Expected result:
----------------
T_OPEN_TAG: '<?php '
T_STRING: 'ob_start'
(
)
;
T_WHITESPACE: ' '
T_CLOSE_TAG: '?>'
Actual result:
--------------
In about 50% I get:
----------------------------
<
?
T_STRING: 'php'
T_WHITESPACE: ' '
T_STRING: 'ob_start'
(
)
;
T_WHITESPACE: ' '
T_CLOSE_TAG: '?>'
the other 50% I get:
----------------------------
T_OPEN_TAG: '<?php '
T_STRING: 'ob_start'
(
)
;
T_WHITESPACE: ' '
T_CLOSE_TAG: '?>'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 15:00:02 2025 UTC |
This might help... PHP 5.0.2, Apache 2.0.52 Test code: ---------------------------- <?php echo '<pre>'; print_r( token_get_all('<?php $a=$b;')); echo '</pre>'; ?> Expected result (I think): ---------------------------- Array ( [0] => Array ( [0] => 365 [1] => <?php ) [1] => Array ( [0] => 308 [1] => $a ) [2] => = [3] => Array ( [0] => 308 [1] => $b ) [4] => ; ) Result: ------------------------ Array ( [0] => < [1] => ? [2] => Array ( [0] => 307 [1] => php ) [3] => Array ( [0] => 369 [1] => ) [4] => Array ( [0] => 309 [1] => $a ) [5] => = [6] => Array ( [0] => 309 [1] => $b ) [7] => ; ) Result after restarting Apache: --------------------------------- Array ( [0] => Array ( [0] => 366 [1] => Array ( [0] => 309 [1] => $a ) [2] => = [3] => Array ( [0] => 309 [1] => $b ) [4] => ; ) Hope it helps...