|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-08 12:59 UTC] marcus dot mueller at grintsch dot com
Description:
------------
I'm not quite sure this is a bug, so if it isn't please excuse my ignorance.
Running the script below on a produces a "PHP Parse error: memory exhausted".
Lowering 9994 to 9993 doesn't expose this behaviour and produces the expected result (well, "boolean false" oc).
From the PHP manual: "PHP imposes no boundary on the size of a string; the only limit is the available memory of the computer on which PHP is running".
The box I'm running this on has 4GB.
Reproduce code:
---------------
<?php
for($foo='',$i=0;$i<9994;$i++) {
$foo.='1+';
}
eval('$foo='.$foo.' 1;var_dump($foo);');
for($foo='',$i=0;$i<9994;$i++) {
$foo.='!';
}
eval('$foo='.$foo.' 1;var_dump($foo);');
?>
Expected result:
----------------
int 9995
boolean true
Actual result:
--------------
int(9995)
Parse error: memory exhausted in not.php(10) : eval()'d code on line 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 02:00:01 2025 UTC |
Thank you for your quick reply. > You have a parse error in your second block of code. > eval('$foo='.$foo.' 1;var_dump($foo);'); > > Essentially you have > $foo = 9994!!!!! 1; var_dump($foo); I beg to differ. Please look again. There is no parse error in the second block. $foo contains 9994 times the "!" followed by "1". Please check again with the following code. <?php for($foo='',$i=0;$i<9994;$i++) { $foo.='!'; } echo strlen($foo)."<br/>\n"; $bar = '$foo='.$foo.' 1;var_dump($foo);'; echo $bar."<br/>\n"; eval($bar); ?> And as I mentioned before the example runs absolutely fine (no parse rror, no memory exhausted error) when lowering 9994 to 9993.