Created
February 24, 2018 09:47
-
-
Save capfsb/013711a6c8864cfa854f34978add8ac9 to your computer and use it in GitHub Desktop.
a.php
This file contains 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 | |
function someFunc($storage){ | |
return (function($a) use (&$storage) | |
{ | |
return $storage+=$a; | |
}); | |
} | |
$a = someFunc(2); | |
echo $a(2); // 4 | |
echo $a(5); // 9 | |
echo $a(1); // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment