First of all, this problem should not appear here, Because before using ThinkPHP3.1.2, the use of rich text editor to save text, directly from the database to take out the data can be normal display, instead of ThinkPHP3.2.3, thinkphp from the database HTML code Display page does not parse, direct display of the source code, the problem is actually very simple , but was very anxious, did not think.
Usually after the problem, to start thinking from the source, to find the reason, not immediately Baidu or Google. When I got up this morning, I thought about it, all the data files are displayed from my database, and the problem should appear in the data acquisition and data display. Sure enough, open the database to look at the text stored inside, he is this kind of:
We found that some special symbols < > "And so on are encoded, not previously directly stored tags, so now there are two solutions, one is to get the database file transcoding, and the second is in the storage time to convert, using Htmlspecialchars_ The decode () function. Individuals tend to use the second, all problems are solved at the source.
$m = m ('Txt'); $res= $mCreate (); $content= I ('post.txt_content'); $m->txt_content =Htmlspecialchars_decode ($content); //Encode the content of the article when it is in storage $m->txt_img = $info ['file']['Savename']; //get local time on server (China)Date_default_timezone_set ('PRC'); $time= Date ("y-m-d h:i:s"); $m->txt_time = $time;//Attach on creation time$idNum= $m->add ();
When you plug it in again, it's what you see in the database.
Get
thinkphp from the database HTML code Display page does not parse