13.PHP 预定义接口 --- Closure 类

来源:互联网 发布:mill9%2e1编程教程 编辑:程序博客网 时间:2024/04/27 21:32

这里写图片描述
这里写图片描述

<?phpclass A {    private static $sfoo = 1;    private $ifoo = 2;}$cl1 = static function() {    return A::$sfoo;};$cl2 = function() {    return $this->ifoo;};$bcl1 = Closure::bind($cl1, null, 'A');$bcl2 = Closure::bind($cl2, new A(), 'A');echo $bcl1(), "<br/>";  // 1echo $bcl2(), "<br/>";  // 2

这里写图片描述
这里写图片描述


http://php.net/manual/zh/class.closure.php

0 0
原创粉丝点击