December 2001
Intermediate to advanced
520 pages
13h 42m
English
In your programming you've most certainly had occasion to define and use your own functions—it's a wonderful tool, helping to organ ize your code and saving you time. What you may not have experimented with is the capability to use recursion with your functions.
Recursion is the act of a function calling itself.
function function_name () {
// Other code.
function_name ();
}
The end result is that your functions can act both as originally intended and as a loop. The one huge warning when using this technique is to make sure your function has an “out” clause. For example, the following code will run ad infinitum.
function add_one ($n) {
$n++;
add_one ($n);
}
add_one (1);
The lack of a condition that determines ...
Read now
Unlock full access