Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP匿名函数中没有此函数_Php_This_Anonymous Function - Fatal编程技术网

PHP匿名函数中没有此函数

PHP匿名函数中没有此函数,php,this,anonymous-function,Php,This,Anonymous Function,如果没有这个,如何在类中声明函数 <?php class modul { var $i=1; var $j=1; public function init(){ $test1 = function($vRecord){ return 'zwrot'; }; echo "<pre>"; print_r($test1); echo "</pre

如果没有这个,如何在类中声明函数

<?php

class modul {

    var $i=1;
    var $j=1;

    public function init(){
        $test1 = function($vRecord){
            return 'zwrot';
        };
        echo "<pre>";
        print_r($test1);
        echo "</pre>";
    }

}

$modul = new modul();
$modul->init();
如何在没有键的情况下传递函数:“this”?我希望打印和资源中有一个纯函数,如下所示:

代码:

Closure Object
(
    [parameter] => Array
        (
            [$vRecord] => 
        )

)
您可以定义一个:


本例中的
this
是类的一部分,不是我知道的函数yes,但可以在对象内声明纯匿名函数?如果
init
函数是静态的,则没有
$this
。从你的问题中不清楚这是否是一个可用的选项。我喜欢这种类型的问题!看看,我想这就是你想要的是的!非常感谢!
<?php
$test2 = function($vRecord){
    return 'zwrot';
};
echo "<pre>";
    print_r($test2);
echo "</pre>";
Closure Object
(
    [parameter] => Array
        (
            [$vRecord] => 
        )

)
    $test1 = static function($vRecord){
        return 'zwrot';
    };