Php parses the dom and all Chinese characters are programmed with something similar to ascii-php Tutorial

Source: Internet
Author: User
After php parses the dom, Chinese characters are programmed to be similar to ascii. php & nbsp; after dom parsing, & nbsp; Chinese characters are programmed to be similar to ascii, but Chinese characters are normally displayed on the webpage, after viewing the source code, you can view the source code in ascii format. & lt; div & nbsp; contentScore8405 & gt; & nbsp; & after nb php parses the dom, Chinese characters are programmed to be similar to ascii.
After php parses the dom, Chinese characters are programmed to something similar to ascii, but Chinese characters are normally displayed on the webpage, and the source code is converted into ascii.
View the source code



In the past two months, WeChat marketing has been spreading like crazy. I have been paying attention to this new thing. Gradually, I have some opinions. I 'd like to share it with you today.



I first paid attention to "Wang Lihong". I told him a sentence, and he quickly returned a long speech. then I did not talk about it. From the very beginning, I knew that this must have been done by machines. out of curiosity, I talked to him from time to time and did not reply much. It was also the kind of things that I could say to anyone. One day, he suddenly received a WeChat message from Wang Li Hong, which said about his concert in Jiaxing. I think this is also recorded in the WeChat platform.



Idea: put the data into the $ ContentBox variable after processing the data. if $ ContentBox-> nodeValue is directly output, the webpage and source code are displayed normally, but the html tag (such as p src) and the image is gone. if you copy $ ContentBox to another dom, the webpage is displayed normally, but the source code text is similar to ascii (the labels and images are not lost ), as follows,
$Target = new DOMDocument;
$Target->appendChild($Target->importNode($ContentBox, true));

echo $Target->saveHTML();


What is the reason? how can this problem be solved?


------ Solution --------------------
$ Target = new DOMDocument ('1. 0 ', 'utf-8'); $ ContentBox = $ Target-> importNode ($ ContentBox, true); echo $ Target-> saveXML ($ ContentBox );

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.