Laravel's blade template displays formatted content
阿神
阿神 2017-05-16 16:54:55
0
1
513

There is some content that is formatted when I save it to the database and is obtained using a rich text editor, such as the body of the article:

<p><span style="color: rgb(226, 139, 65);">Sorry,本站已暂停访问,报名请联系xxxx</span><br></p><p style="margin-left: 40px;"><span style="color: rgb(65, 140, 175);">或访问其他站点!</span></p><p style="margin-left: 80px;"><span style="color: rgb(32, 147, 97);">谢谢~~</span></p>

Now I want to take it out for display, but when I use {{ $content }} to output on the page, the output is not according to the style, but like this:

Document description:

By default, Blade's {{ }} expression is automatically processed through PHP's htmlentities function to prevent XSS attacks. If you do not want your data to be escaped, please use the following syntax:

Hello, {!! $name !!}.

I replaced {{ $content }} with {!! $content !!}, and the result is still as shown above.

I am a beginner, how to solve it?

阿神
阿神

闭关修行中......

reply all(1)
伊谢尔伦

Laravel has both escaping and non-escaping when outputting data, that is, {{$name}} and {!! $name !!}
Examples are as follows:


The output result is

Conversely:

No more reading, what the author needs is to convert html entities into characters. After taking the data out of the database, use the
html_entity_decode() function to transform it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template