加入收藏 | 设为首页 | 会员中心 | 我要投稿 无锡站长网 (https://www.0510zz.cn/)- 运维、开发、CDN、操作系统、语音技术!
当前位置: 首页 > 教程 > 正文

解析PHP闭包及Clourse类方法的作用

发布时间:2022-08-11 11:24:39 所属栏目:教程 来源:互联网
导读:PHP Clourse(闭包类) 浅析 0x00 前言 闭包是指在创建时封装周围状态的函数。即使闭包所在的环境不存在了,闭包中封装的状态依然存在。 在 PHP 里所有的闭包都是 Clourse 类所实例化的一个对象,也就是说闭包与其他 PHP 对象没有什么不同。而一个对象就必然有

 
     * @return Closure Returns the newly created Closure object or FALSE on failure
 
     */
 
    function bindTo($newthis, $newscope = 'static') { }
 
    /**
 
     * This method is a static version of Closure::bindTo().
 
     * See the documentation of that method for more information.
 
     * @static
 
     * @link http://www.php.net/manual/en/closure.bind.php
 
     * @param Closure $closure The anonymous functions to bind.
 
     * @param object $newthis The object to which the given anonymous function should be bound, or NULL for the closure to be unbound.
 
     * @param mixed $newscope The class scope to which associate the closure is to be associated, or 'static' to keep the current one.
 
     * If an object is given, the type of the object will be used instead.
 
     * This determines the visibility of protected and private methods of the bound object.
 
     * @return Closure Returns the newly created Closure object or FALSE on failure
 
     */
 
    static function bind(Closure $closure, $newthis, $newscope = 'static') { }
 
    /**
 
     * Temporarily binds the closure to newthis, and calls it with any given parameters.
 
     * @link http://php.net/manual/en/closure.call.php
 
     * @param object $newThis The object to bind the closure to for the duration of the call.
 
     * @param mixed $parameters [optional] Zero or more parameters, which will be given as parameters to the closure.
 
     * @return mixed
 
     * @since 7.0
 
     */
 
    function call ($newThis, ...$parameters) {}
 
     
 
    /**
 
     * @param callable $callable
 
     * @return Closure
 
     * @since 7.1
 
     */
 
    public static function fromCallable (callable $callable) {}
 
}

(编辑:无锡站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读