Skip to content

Instantly share code, notes, and snippets.

@drench
Created June 22, 2010 14:26
Show Gist options
  • Save drench/448528 to your computer and use it in GitHub Desktop.
Save drench/448528 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
function counter ($n) {
error_log("starting counter at $n");
return function () use (&$n) {
return ++$n;
};
}
$c1 = counter(20);
$c2 = counter(77);
$i = 10;
while ($i-- > 0) {
echo $c1() . "\t" . $c2() . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment