How to ensure normal parsing when PHP, MySQL, browser code is not unified

Source: Internet
Author: User
Tags php and mysql

Ideally, the three codes are unified into GBK or utf-8, so the parsing is normal. But how can it not be unified? For example:--php encoding is UTF-8--MYSQL encoding is utf-8--browser encoding is GBK at this time, just consider PHP and browse ...

Ideally, the three codes are unified into GBK or utf-8, so the parsing is normal. But how can it not be unified?

Like what:

--php's code is utf-8.

--mysql's code is utf-8.

--The browser encoding is GBK

At this point, just consider PHP and the browser can, because PHP and MySQL encoding is consistent, can not be considered. And how to tell the browser, PHP back to the browser is something to use utf-8, please use utf-8 parsing?

Answer:

(1) One of the methods is the header function we used in PHP. Header ("Content-type:text/html;charset=utf-8");

(2) The second method is that we set it in the META tag of the HTML code.

And if the code between PHP and MySQL is not uniform, how to tell each other's own code?

Answer:

(1) One of the methods is to modify the MySQL server in MySQL to accept PHP and return to PHP data encoding, set Character_set_client=utf8; is to tell the MySQL server current PHP sent by the UTF8 encoding. Set Character_set_result=utf8; is to tell the MySQL server that PHP can only accept utf8 things.

(2) The second method is a simplification of the wording. is to set names UTF8 directly in the PHP code, which means that I only send and receive UTF8 encoded things in PHP. is the simplification of method one above.

After the cities after the start prev up 1.85% gem rise 3.67%:http://licai.daiyuline.com/caijingxinwen/337.html

Hot money can quickly return a A-share key depends on a little "octopus investment Banking": http://licai.daiyuline.com/caijingxinwen/336.html

How to ensure normal parsing when PHP, MySQL, browser code is not unified

Related Article

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.