Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.3 blade decoding HTML Special Characters

Tags:

laravel

I save some HTML Code in my Database. When I got that data to the blade, CSS not working on.

In the Page Source Code I found that < shows as '& lt;'

What method have I to use to convert & lt to <

Is there anybody to help me?

like image 922
Md. Harun Or Rashid Avatar asked Nov 15 '16 10:11

Md. Harun Or Rashid


People also ask

What is @yield used for in Laravel?

In Laravel, @yield is principally used to define a section in a layout and is constantly used to get content from a child page unto a master page.

How do you remove special characters in HTML?

Answer: Using htmlspecialchars() function We can remove the HTML special characters from the string using the PHP htmlspecialchars() function. This function converts the HTML special characters within the string into HTML entities. Some most used special characters are: & (ampersand) will be converted to &amp.

Can we use HTML in Laravel?

Creating the layout is an important part of any project. Realizing this, Laravel comes with a Blade templating engine which generates HTML based sleek designs and templates. All Laravel views built using Blade are located in resources/views.


2 Answers

Change your syntax from {{ }} to {!! !!} that should do the trick

like image 153
Laemol Avatar answered Oct 02 '22 13:10

Laemol


use below code:

{!! htmlspecialchars($post->description)!!}

This will solve your problem.

like image 20
smk pobon Avatar answered Oct 02 '22 12:10

smk pobon