array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'closure.fromcallable.php', 1 => 'Closure::fromCallable', ), 'up' => array ( 0 => 'class.closure.php', 1 => 'Closure', ), 'prev' => array ( 0 => 'closure.call.php', 1 => 'Closure::call', ), 'next' => array ( 0 => 'class.stdclass.php', 1 => 'stdClass', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'language/predefined/closure/fromcallable.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.1.0)
Closure::fromCallable — 将 callable 转换为闭包
使用当前范围从给定的 callback
创建并返回一个新的
匿名函数。
此方法检查 callback
函数在作用域是否可调用,
如果不能,就抛出 TypeError。
注意:
从 PHP 8.1.0 开始,First-class 可调用语法 的语义与此方法相同。
callback
要转换的回调。