Bug #54566 [Opn->Bgs]: bug into recursive function
| From: | dtajchreber@php.net | Date: | Tue, 19 Apr 2011 00:58:19 +0000 |
| Subject: | Bug #54566 [Opn->Bgs]: bug into recursive function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160274@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54566&edit=1
ID: 54566
Updated by: dtajchreber@php.net
Reported by: paridin at paridin dot com
Summary: bug into recursive function
-Status: Open
+Status: Bogus
Type: Bug
Package: Output Control
Operating System: Linux,Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
return foo(++$i); instead of return foo($i++);
foo($i++); will always call foo(0);
Previous Comments:
------------------------------------------------------------------------
[2011-04-19 02:10:49] paridin at paridin dot com
Description:
------------
When you try to make recursive function and send the counter directly.
you have
an error, to fix this, you need increment before the counter, and after
send
this counter.
Test script:
---------------
<?php
function foo($i){
if( $i < 100){
echo " ".$i;
return foo($i++); // bug
}else{
return $m="\r\nEnd Process";
}
}
$i=0;
echo foo($i);
?>
Expected result:
----------------
1 2 3 4 5 6 7 8 ... 97 98 99 100
End Process
Actual result:
--------------
00000...0000000 Fatal error: Allowed memory size of 134217728 bytes
exhausted
(tried to allocate 523800 bytes) in /home/paridin/public_html/bug.php on
line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54566&edit=1