At 5/30/2003 04:49 PM, Martin Helie wrote:

> function test() {
>     static $i = 0;
>     if( $i < 10 ) {
>         $i++;
>         test();
>     }
>     echo "I'm here";
> }
>
> 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".

Why? The "I'm here" line is outside the conditional. The function will still complete independent of the conditional. If $i is greater than ten, the pointer just skips the contents of the if/then and continues on the next line after it. Here's a better illustration:


function gooble($alGore) { echo "This is a "; if ($alGore!="President") { echo "longer "; } echo "sentence.<br />"; } gooble("Vice President"); gooble("Crazy Mountain Man); gooble("President");

If you want the function to terminate when the conditional is false, then you need an Else statement to do so, otherwise it's going to keep going.

--
S. Keller
UI Engineer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Pkwy.
Anchorage, AK 99508
907.770.6200 ext.220
907.336.6205 (fax)
Email: [EMAIL PROTECTED]
Web: www.healthtvchannel.org


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



Reply via email to