Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //To use the var $name in the closure you need to add use ($name) as below
- $name = 'Elvis';
- $greet = function() use ($name){
- echo "Hello there, $name.";
- };//Semi colon must be at end of closure
- //To call/Use the closure
- $greet();
- ?>
Add Comment
Please, Sign In to add comment