Created
July 21, 2012 17:48
-
-
Save passion8/3156543 to your computer and use it in GitHub Desktop.
universal solution for breaking recursion loop ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Author : Paritosh Piplewar | |
| Description : solution for recursion . | |
| */ | |
| function recursiveFunction(){ | |
| static $breaking_point = 1; | |
| // here 5 is the extreme limit which breaks the function | |
| if($breaking_point == 5){ | |
| break; | |
| } | |
| /* | |
| for simplicity i am just adding printing statement . | |
| you can add anything | |
| */ | |
| echo "this is simple print statement"; | |
| $breaking_point++; | |
| recursiveFunction(); | |
| return; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment