Home >Backend Development >PHP Tutorial >mysql - php stores html code into the database. How to output it according to the original style when reading it?

mysql - php stores html code into the database. How to output it according to the original style when reading it?

WBOY
WBOYOriginal
2016-08-04 09:19:181259browse

After exporting, the html is also output.
Or is there any other storage method?
mysql - php stores html code into the database. How to output it according to the original style when reading it?

Original style

mysql - php stores html code into the database. How to output it according to the original style when reading it?

Reply content:

After exporting, the html is also output.
Or is there any other storage method?
mysql - php stores html code into the database. How to output it according to the original style when reading it?

Original style

mysql - php stores html code into the database. How to output it according to the original style when reading it?

When you use the rich text editing box to edit content storage, there must be automatically generated html tags! It must have come out when reading the area, but when you access it through the browser, it should be in the format when you save it. If the html tag is displayed when accessing the browser, it means that the program needs to be adjusted

UEditor stores HTML format in the database. When you output, just throw it to the browser. The browser will parse it. If not, use Ajax request.

It should be that when you output, the output is text/plain, and the browser outputs the obtained content as plain text.

Add a header('Content-Type: text/html; charset=utf-8');, so that the browser will know that this is html.

Did you use any framework? When accepting parameters, the html information is filtered, so there will be no html information when written into the library

Just use the MySQL text type to store rich text, and directly store the html code in the database

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