Bug #54566 [NEW]: bug into recursive function

From: Date: Tue, 19 Apr 2011 00:10:49 +0000
Subject: Bug #54566 [NEW]: bug into recursive function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160273@lists.php.net to get a copy of this message
From: Operating system: Linux,Windows PHP version: Irrelevant Package: Output Control Bug Type: Bug Bug description:bug into recursive function 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 bug report at http://bugs.php.net/bug.php?id=54566&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54566&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54566&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54566&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54566&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54566&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54566&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54566&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54566&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54566&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54566&r=support Expected behavior: http://bugs.php.net/fix.php?id=54566&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54566&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54566&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54566&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54566&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54566&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54566&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54566&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54566&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54566&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54566&r=mysqlcfg

« previous php.bugs (#160273) next »