Hi! This I simply don't understand why this code executes that way. So there is only inportant to put return after recursive call and it works like i wan't. I sometimes write small C programs and I don't remeber that code like this have to work that way.... Hm.
-- bye, Uros mailto:[EMAIL PROTECTED] Sunday, March 31, 2002, 1:10:30 AM, you wrote: LTW> On Sat, 2002-03-30 at 15:59, 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. LTW> No, there should be 10 of them, since every time Test() returns, LTW> the function carries on executing. If you only want one 'j' LTW> printed then put a return statement after the call to Test(): LTW> function Test() LTW> { LTW> static $count = 0; LTW> $count++; LTW> echo $count; LTW> if ($count < 10) { LTW> Test(); LTW> return; LTW> } LTW> echo "j"; LTW> } LTW> Test(); LTW> Cheers! LTW> Torben LTW> -- LTW> Torben Wilson <[EMAIL PROTECTED]> LTW> http://www.thebuttlesschaps.com LTW> http://www.hybrid17.com LTW> http://www.inflatableeye.com LTW> +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php