更确切地说,函数声明参数中使用的"callable".喜欢下面这个.
function post($pattern, callable $handler) {
$this->routes['post'][$pattern] = $handler;
return $this;
}
Run Code Online (Sandbox Code Playgroud)
它对我们有什么好处?
为什么以及如何使用它?
也许这对你来说非常基础,但是,我已经尝试过寻找它而我却得不到任何答案.至少,我无法理解.
希望得到一个假人的答案.我是编码的新手...... XD
php callable type-hinting function-declaration type-declaration