PHP Fatal error: Cannot use $this as parameter

后端 未结 3 1526
悲哀的现实
悲哀的现实 2020-12-11 07:38

I\'ve the following PHP method which is part of the codebase which was working fine:



        
3条回答
  •  不知归路
    2020-12-11 07:59

    Just skip $this argument, change

    function ($this) {
        return $this;
    }
    

    to

    function () {
        return $this;
    }
    

    Look at Example #5 Automatic binding of $this on Anonymous functions page:

    testing();
    $function();
    ?>
    

提交回复
热议问题