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';
};