小编S. *_*ody的帖子

关键字"callable"在PHP中做什么

更确切地说,函数声明参数中使用的"callable".喜欢下面这个.

function post($pattern, callable $handler) {
    $this->routes['post'][$pattern] = $handler;
    return $this;
}
Run Code Online (Sandbox Code Playgroud)

它对我们有什么好处?

为什么以及如何使用它?

也许这对你来说非常基础,但是,我已经尝试过寻找它而我却得不到任何答案.至少,我无法理解.

希望得到一个假人的答案.我是编码的新手...... XD

编辑:这是我从上面复制上述代码的链接:link

php callable type-hinting function-declaration type-declaration

10
推荐指数
2
解决办法
854
查看次数