Skip to content

Instantly share code, notes, and snippets.

@passion8
Created July 21, 2012 17:48
Show Gist options
  • Save passion8/3156543 to your computer and use it in GitHub Desktop.
Save passion8/3156543 to your computer and use it in GitHub Desktop.
universal solution for breaking recursion loop ?
<?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