Using Recursive Functions

The ability of a function to call a copy of itself is called recursion. Recursion is useful to solve many types of programming problems, such as parsing and node tree searches. There are two types of recursion: linear and nonlinear. In linear recursion, a function calls only one copy of itself each time. In nonlinear recursion, a function calls more than one copy of itself each time.

The only problem with recursion is that it consumes large amounts of system resources. For example, PHP programs that perform over 200 recursive calls run the risk of collapsing the PHP stack, which would mean a depth of 200 linear recursions. Nonlinear recursions require more memory and will probably collapse the PHP stack in half or less ...

Get Oracle Database 10g Express Edition PHP Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.