The ideal situation is to unify the three codes into gbk or UTF-8, so that resolution is normal. But how can it be different? For example, -- PHP encoding is UTF-8 -- MySQL encoding is UTF-8 -- the browser encoding is gbk. in this case, you only need to consider PHP and browsing.
The ideal situation is to unify the three codes into gbk or UTF-8, so that resolution is normal. But how can it be different? For example, -- PHP encoding is UTF-8 -- MySQL encoding is UTF-8 -- the browser encoding is gbk. in this case, you only need to consider PHP and browsing...
The ideal situation is to unify the three codes into gbk or UTF-8, so that resolution is normal. But how can it be different?
For example:
-- The PHP code is UTF-8.
-- MySQL is UTF-8 encoded
-- The browser code is gbk.
At this time, you only need to consider the PHP and the browser, because the PHP and MySQL encoding is consistent, you can not consider. How can I tell the browser that what PHP returns to the browser is UTF-8, so please use UTF-8 for parsing?
Answer:
(1) one of the methods is the header function we use in PHP. Header ("Content-type: text/html; charset = utf-8 ");
(2) method 2 is set in the meta tag of html code.
If the encoding between PHP and MySQL is not uniform, how can we tell each other their own encoding?
Answer:
(1) one of the methods is to modify the encoding when the MySQL server receives PHP Data and returns the data to PHP in MySQL. set character_set_client = utf8; it indicates that the current PHP code sent from the MySQL server is utf8. Set character_set_result = utf8; indicates that the MySQL server currently supports utf8 only in PHP.
(2) method 2 is a simplified method. Set names utf8 directly in the PHP code, indicating that PHP only sends and accepts utf8 encoding. Simplified in method 1 above.
Disclaimer: This article only represents the author's personal opinion and has nothing to do with this site. Its originality, as well as the statement text and content in this article have not been confirmed by this site, this article and all or part of the content, the authenticity, integrity, timeliness of this site do not make any warranty or commitment, for your reference only, please verify the relevant content on your own.