Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the e() method in laravel views for?

I was digging through laravel and I went through how the blade views are interpreted and what I came across was that:

This:

{{ $tenant->name }}

Translates to this:

<?php echo e($tenant->name); ?>

I don't understand what the e() method is for? I could not find it on the php.net too so I am guessing it is a part of laravel 5 itself. But what does it do?

like image 566
Rohan Avatar asked Oct 12 '15 07:10

Rohan


People also ask

How to create a simple view in Laravel?

Laravel offers a simple view that routes to home. Loading a view in the controller is easy. You just need to add ` view (‘viewname’)` method while returning from the controller method. ` view () ` is a global helper in Laravel. In this method, you just need to pass the name of the view.

How to share data with all views in Laravel?

4. Share Data with all Views: If you want to be shared between all the different views in a Laravel application then you can do that by using the share method. This is a View facade method so you will need to add use Illuminate\Support\Facades\View; this line.

What is Laravel?

Laravel is an MVC based PHP framework. In MVC architecture, V stands for View. The View is data that is going to be displayed to the user on their browser and the user can interact with it. It is simply an interface provided to the user for interaction. Laravel used a powerful templating engine called Blade.

What is V in Laravel MVC?

In MVC architecture, V stands for View. The View is data that is going to be displayed to the user on their browser and the user can interact with it. It is simply an interface provided to the user for interaction. Laravel used a powerful templating engine called Blade. The extension for this file used here is filename.blade.php.


1 Answers

from the docs:

e()

The e function runs htmlentities over the given string:

echo e('<html>foo</html>');

// &lt;html&gt;foo&lt;/html&gt;

http://laravel.com/docs/5.1/helpers#method-e

like image 50
Glad To Help Avatar answered Sep 22 '22 07:09

Glad To Help