I beleive he is talking about calling a function recursively, as in:
function foo()
{
foo();
}
The above would create an infinite loop, but this is valid. Recursive functions tend to make your head spin. But they work the same as a normal function does, in that, you include a return; statement to pass control back to the calling code. In this case the calling code could be the same function, in which case you control those nested calls with return statements until the whole thing is finished with whatever it is doing. Does that make sense?? Here is an example.
function foo($bar = false)
{
if ($bar)
{
// This value is returned to the recursively called foo
return 'Hello, world!';
}
else
{
// A return here will return the value returned by the recursively called foo()
// Otherwise that returned value would be lost to oblivion.
return foo(true);
}
}
echo foo();
The above limits the recursive call on foo to only once, on the second call $bar is true and the value 'Hello, world!' is returned and output.
I've seen some benchmarking that indicates recursive functions can really slow down a script, in my own experience whenever I've needed one however, it hasn't been noticable.
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design