Created
April 9, 2013 07:13
-
-
Save MarcelloDuarte/5343629 to your computer and use it in GitHub Desktop.
Even wondered how to use recursion in PHP closures?
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 | |
$decrease = function($self, $number) { | |
if ($number >= 0) { | |
echo $number . PHP_EOL; | |
$self($self, --$number); | |
} | |
}; | |
$decrease($decrease, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:) and changing decrease inside decrease?
nightmare version