<?php
function generator($start, $step) {
$step = 1;
}
return function() use (&$start, $step) {
return $start += $step;
};
}
$counter = generator(2, 2);
echo $counter();
echo $counter();
echo $counter();
PD9waHAKCmZ1bmN0aW9uIGdlbmVyYXRvcigkc3RhcnQsICRzdGVwKSB7CglpZiAoZnVuY19udW1fYXJncygpID09IDEpIHsKCQkkc3RlcCA9IDE7Cgl9CgkKCXJldHVybiBmdW5jdGlvbigpIHVzZSAoJiRzdGFydCwgJHN0ZXApIHsKCQlyZXR1cm4gJHN0YXJ0ICs9ICRzdGVwOwoJfTsKfQoKJGNvdW50ZXIgPSBnZW5lcmF0b3IoMiwgMik7CgplY2hvICRjb3VudGVyKCk7CmVjaG8gJGNvdW50ZXIoKTsKZWNobyAkY291bnRlcigpOw==