06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Blade Templates 174<br />

Of course, just like plain PHP views, Blade views may be returned from routes using the global view<br />

helper function:<br />

1 Route::get('blade', function () {<br />

2 return view('child');<br />

3 });<br />

Displaying Data<br />

You may display data passed to your Blade views by wrapping the variable in “curly” braces. For<br />

example, given the following route:<br />

1 Route::get('greeting', function () {<br />

2 return view('welcome', ['name' => 'Samantha']);<br />

3 });<br />

You may display the contents of the name variable like so:<br />

1 Hello, {{ $name }}.<br />

Of course, you are not limited to displaying the contents of the variables passed to the view. You<br />

may also echo the results of any PHP function. In fact, you can put any PHP code you wish inside<br />

of a Blade echo statement:<br />

1 The current UNIX timestamp is {{ time() }}.<br />

Note: Blade {{ }} statements are automatically sent through PHP’s htmlentities function<br />

to prevent XSS attacks.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!