How and why use curly braces: return $this->{$this->action}();

前端 未结 2 1242
悲&欢浪女
悲&欢浪女 2021-01-23 01:29

so in first part i made 2 object, instantiate two classes (one we generate from createController function)

$loader = new Loader(); 
$controller = $loader->cre         


        
2条回答
  •  囚心锁ツ
    2021-01-23 01:56

    You can simply put the $this->action in another local variable and then, call it:

    $action = $this->action;
    $this->$action();
    

提交回复
热议问题