我期待在Laravel文檔,我看到這個片段:PHP/Laravel的魔法,這是如何工作的?
class UserController extends BaseController {
/**
* The layout that should be used for responses.
*/
protected $layout = 'layouts.master';
/**
* Show the user profile.
*/
public function showProfile()
{
$this->layout->content = View::make('user.profile');
}
}
,我們可以清楚地看到這 - $>佈局=「layouts.master」。然而,他們定義的佈局對象(我的理解僅僅是一個基礎PHP字符串,而沒有一個叫內容字段,通過一個孩子......
$this->layout->content = View::make('user.profile');
哪有一個字符串都定義了一個名爲內容字段
當我繼承BaseController並嘗試爲其賦值 $這個 - >佈局 - >內容,爲什麼會出現以下錯誤:「嘗試 分配的財產非對象「?
該代碼片段不能單獨使用。另一個類正在改變'$ layout'(通過setter方法),或者代碼片段完全錯誤。鏈接到你發現這個的文檔? – 0b10011 2014-09-25 19:45:45
http://laravel.com/docs/master/templates這是他所指的文檔。 – mschuett 2014-09-25 19:51:04