Sorry if this is completely stupid, but can anyone explain this, assuming
the following code:

function test() {
    static $i = 0;

    if( $i < 10 ) {
        $i++;
        test();
    }
    echo "I'm here";
}

test();

I am a little surprised to find that even when $i < 10 and test() is invoked
again, the current function call executes all the way through to echoing
"I'm here".

I would've thought current execution would be terminated as soon as the
function is called again, and that I'd get "I'm here" only once we're out of
the loop (ie, $i == 10).

Thanks for any pointers.

Martin Helie



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to