Created
June 13, 2012 16:23
-
-
Save mbunge/2925070 to your computer and use it in GitHub Desktop.
Anonymus Function Test
This file contains 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 | |
$stdClass = new stdClass(); | |
$stdClass->value = 'HELLO WOLRD'; | |
//return message defined by $stdClass::value with a context | |
//use $stdClass as scope | |
$lambda = function($context) use ($stdClass) | |
{ | |
$msg = $context . ': ' . $stdClass->value; | |
return $msg; | |
}; | |
echo $lambda('TEXT'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment