Home >Backend Development >PHP Tutorial >HTML string parsing display
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?
Picture description
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?
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