The convention.php in the thinkphp conf file has a configuration option
' Default_filter ' => ' htmlspecialchars ',//default parameter filtering method for I function ...
This method is turned on by default. In other words, the data we store in the database is htmlspecialchars by this function.
I used the kindeditor Rich Text editor in my project (maybe you're using Ueditor\ckeditor), edited the content of the article through a rich-text editor, and then stored it in the database and then read it from the database to the page.
In this process, I encountered a problem, when I was in the Insert method directly display I will be submitted to the database text data, the normal parsing into the HTML page, but when I read the HTML data from the database, the content of the article becomes an entire paragraph of HTML code. The dump outputs the contents of the array I read and can be clearly seen as being escaped.
1. What is stored in the database and an example of the content of the article read out:
2. Content effects parsed in HTML pages:
"<p>
<span style=" White-space:pre "> </span> <span style= "White-space:pre"
> </span></p> "
It is obvious that the content that should have been HTML tags is now parsed into the contents of the text, with double quotes added to the outermost part of the text.
The normal display should be no double quotes. The database reads the data is the HTML page source code, then inserts the HTML page, the label is explained, the content inside the label displays the page.
Through the above analysis, can be determined, is thinkphp in the process of content storage automatically escape processing, resulting in the contents of the database into the escaped content, read out again when the HTML will automatically be the content of the original label to escape into the body text.
Therefore, decisively to the TP directory to find convention.php configuration file, the Default_filter function is disabled, later need to use the time to manually call it.
Test again, this time it solves the problem.