PHP Recursive Function

PHP also supports recursive function call like C/C++. In such case, we call current function within function. It is also known as recursion.

It is recommended to avoid recursive function call over 200 recursion level because it may smash the stack and may cause the termination of script.

Example 1: Printing number

Output:

Example 2 : Factorial Number

Output:

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *