Home  >  Article  >  Backend Development  >  HTML string parsing display

HTML string parsing display

WBOY
WBOYOriginal
2016-08-04 09:21:131330browse

I have stored a string in html format in the database, and now I need to display and display the correct html format on the interface. How should this be handled? HTML string parsing display

HTML string parsing display

Picture description

Reply content:

I have stored a string in html format in the database, and now I need to display and display the correct html format on the interface. How should this be handled? HTML string parsing display

HTML string parsing display

Picture description

By default, use the {{ $var }} tag to output strings. The Blade template engine will automatically escape (escape) HTML characters. If you need native output, you need to use {!! $var !!} tag!

In order to display it correctly, either there is no p in the page, or the outermost tag in the database must be removed and added to the page

Looking at your picture
It should be that the display page uses htmlspecialchars to escape the html encoding.
Otherwise your database will not display this string on the

html, but the corresponding style

If you use an editor, some editors have escaped the special characters once by javascript when posting, then you can just echo them out when outputting in php. If you use htmlspecilchars() again, they will only The html code is displayed directly instead of parsed.

https://segmentfault.com/q/1010000005995934

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn