PHP Output Chinese garbled solution (reprint)

Source: Internet
Author: User

Recently found in the PHP program on Windows The output of the Chinese garbled situation.

Read a lot of post information can be added on the page:

Http://www.cnblogs.com/leandro/archive/2008/04/21/1368517.html
With the echo output of the Chinese display as garbled, in fact, it should be a variety of server scripts will encounter this problem, is still a coding problem, generally for the sake of encoding compatibility most of the pages are defined as Utf-8<meta http-equiv= "Content-type "Content=" text/html; Charset=utf-8 "/> This time to normal display of Chinese need to convert the encoding method, such as Echo iconv (" GB2312 "," UTF-8 "," Chinese "); There are other ways, such as adding headers to the echo of PHP ( "content-type:text/html;charset=gb2312"); Of course, the Simplified Chinese page can simply, put <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> In the UTF-8 changed to gb2312 actually encountered strange phenomenon, in the local server on the normal display of the page, transmitted on the server echo out garbled, did not carefully ponder over this reason, because through Iconv function GB2312, UTF-8 change position re-coding under normal, but it is certainly Apache, more specifically the PHP service side of the settings caused by different, see php.ini should be able to solve.

Add echo iconv ("GB2312", "UTF-8", "Chinese") on each page, or <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> will be more painful.

Finally, if you see a php.ini file configuration problem, open the php.ini file, locate the;d efault.charset= "UTF-8"--->default.charset= "UTF-8" Remove the preceding semicolon (remove the comment), Restart Apache service, refresh the page, Chinese display is normal.

Record again, hope to help meet the same problem of friends!

PHP Output Chinese garbled solution (reprint)

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.