Thursday, 15 September 2011

php - Laravel undefined variable but variable is defined -



php - Laravel undefined variable but variable is defined -

using laravel setting variable layout in controller:

$this->layout->title = 'foo'; $this->layout->content = view::make('foo.bar');

but when utilize $title in template undefined error:

<title>{{{ $title }}}</title>

but if utilize conditional

<title>{{{ $title or 'default' }}}</title>

i no error , uses $title variable.

according laravel api illuminate\view\view:

protected string $view name of view. protected array $data array of view data.

so pass info view via controller's property, need do:

$this->layout->data = array('title' => 'foo');

php laravel blade

No comments:

Post a Comment