Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created May 7, 2009 15:01
Show Gist options
  • Save seungjin/108142 to your computer and use it in GitHub Desktop.
Save seungjin/108142 to your computer and use it in GitHub Desktop.
php recursion loop
<?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