【发布时间】:2016-04-11 21:19:54
【问题描述】:
我想使用 addMenu 和 menu 功能,但出现此错误:
Using $this when not in object context
我做错了吗?还是有其他方法可以调用这些函数?
我的代码:
class Documentation {
protected $app;
protected $menu = [];
public function __construct(Application $app){
$this->app = $app;
$this->addMenu(["Hello world"]);
}
public static function addMenu($item){
$this->menu[] = $item;
}
public static function menu(){
return $this->menu;
}
}
【问题讨论】:
标签: php class laravel laravel-4