Skip to content

Instantly share code, notes, and snippets.

@blue7wings
Created September 18, 2017 02:52
Show Gist options
  • Select an option

  • Save blue7wings/ab6c4cc176549a9c0189601c15d7e097 to your computer and use it in GitHub Desktop.

Select an option

Save blue7wings/ab6c4cc176549a9c0189601c15d7e097 to your computer and use it in GitHub Desktop.
给无参数定义函数传参
<?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