Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function create_closure( $count ) {
- return function() use ( &$count ) {
- return $count--;
- };
- }
- $closure = create_closure( 10 );
- $another_closure = create_closure( 20 );
- echo $closure(); // 10
- echo $another_closure(); // 20
- echo $closure(); // 9
- echo $closure(); // 8
- echo $another_closure(); // 19
Add Comment
Please, Sign In to add comment