thinkphp from the database HTML code Display page does not parse

Source: Internet
Author: User
Tags local time

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.