Created
September 18, 2017 02:52
-
-
Save blue7wings/ab6c4cc176549a9c0189601c15d7e097 to your computer and use it in GitHub Desktop.
给无参数定义函数传参
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 | |
| function greet() : Closure { | |
| return function($name) { | |
| return 'Hello ' . $name; | |
| }; | |
| } | |
| function call(Closure $func) { | |
| return function($name) use ($func) { | |
| return $func($name); | |
| }; | |
| } | |
| $greet_func = call(greet()); | |
| $msg = $greet_func('Liam'); | |
| echo $msg; // Hello Liam |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment