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, Ur
Hi
One way is to use a variable to track the recursion llike this:
$y will always be 1 as long as it is in recursion only going to 0 on the
last one.
Tom
At 09:59 AM 31/03/2002, Uros Gruber wrote:
>Hi!
>
>This is a code
>
>function Test()
>{
> static $count = 0;
>
> $count++;
> ec
Hi,
Ok, no I understand why. So this explains why every function
must have return. But how can i program for example one
recursion or where to put return so that test would not be
waiting for return but at the end of this recursion i would
like to do something with that $count for example.
Hmm i
On Sat, 2002-03-30 at 16:16, Uros Gruber wrote:
> 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
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
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
>
> 12345678910jj
>
> Why is
Hi!
This is a code
function Test()
{
static $count = 0;
$count++;
echo $count;
if ($count < 10) {
Test ();
}
echo "j";
}
test();
Output is
12345678910jj
Why is there 10 j at the and. If this would work it can be
only one. If $count is grater than 10 it
7 matches
Mail list logo