RE: [PHP] BUG in recursion

From: Date: Tue, 02 Apr 2002 13:15:39 +0000
Subject: RE: [PHP] BUG in recursion
Groups: php.general 
Request: Send a blank email to php-general+get-91112@lists.php.net to get a copy of this message
No, this is NOT a bug. You recurse 10 times down into the function. Therefore, as you come back up and exit the previous call to test(), you complete Test's processing, which is to print j The recursion process is as expected and correct ============================== At 09:59 AM 31/03/2002, Uros Gruber wrote: >Hi! > >This is a code > >function Test() >{ > static $count = 0; > > $count++; > echo $count; > if ($count < 10) { > Test (); > } > echo "j"; >} >test(); > >Output is > >12345678910jjjjjjjjjj > >Why is there 10 j at the and. If this would work it can be >only one. If $count is grater than 10 it does not call itself >but end. Is this maybe a bug or what. > > >-- >lp, > Uros mailto:uros.gruber@sir-mag.com > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#91112) next »