Created
May 7, 2009 15:01
-
-
Save seungjin/108142 to your computer and use it in GitHub Desktop.
php 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 | |
// php loop based on recursion | |
// why do we need while / for statement in program language? | |
// and in php, I cannot pass php function to php function as function arg. :-( | |
// Anonymous functions are available since PHP 5.3.0. http://us2.php.net/manual/en/functions.anonymous.php | |
// I am using 5.2.6 now. | |
class Foo | |
{ | |
public function loop($a,$b) | |
{ | |
if ( $a >= 0 && $b >= $a ) | |
{ | |
print("I am\n"); | |
$a++; $this->loop($a,$b); | |
} | |
} | |
} | |
$foo = new Foo(); | |
$foo->loop(1,4); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment