Created
November 27, 2012 07:12
-
-
Save sineld/4152884 to your computer and use it in GitHub Desktop.
Using Closures with use and new array style @ Php 5.4
This file contains hidden or 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 | |
| $message = ['Good Morning', 'Good Afternoon', 'Good Evening', 'Good Night']; | |
| $greetingsTo = function($to) use($message){ | |
| return $message[rand(0,count($message)-1)].' '.$to; | |
| }; | |
| echo $greetingsTo('Tuana Şeyma'); | |
| // Good Morning Tuana Şeyma | |
| // Good Afternoon Tuana Şeyma | |
| // Good Evening Tuana Şeyma | |
| // Good Night Tuana Şeyma |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment