天天看點

php5更新php7出現Function name must be a string

$obj = new ClassName();
$obj->$fun($arg);
           

在php5上運作正常,在php7上報錯Function name must be a string。

修改方法:

$obj = new ClassName();
$obj->{$fun}($arg);
           

參考