[thelist] recursive PHP functions

Jay Blanchard jay.blanchard at niicommunications.com
Mon Sep 16 10:41:01 CDT 2002

function recursive ($n)
    if ($n > 10) return $n;
	recursive ($n);
echo "The result:".rec1(1)."<br>";

Read it too fast ...

If $n greater than 10 it returns $n. If $n is less than 10 it would then
increment the number and then attempt to call the function again. If it
succeeds it would loop through until $n becomes 11, at which time it would
exit. I don't know that you can call the functions again from within the
function. There are other ways to write this.



More information about the thelist mailing list