The content shared in this article is about the problem of Chinese garbled characters in php plus xmapp. Now I share it with everyone. Friends in need can refer to
php Chinese garbled characters:
a. If you want to use gb2312 encoding, then PHP should output the header: header(“Content-Type: text/html; charset=gb2312”), and add , the encoding format of all files is ANSI, you can open it with Notepad, save as, select the encoding as ANSI, and overwrite the source file.
b. If you want to use utf-8 encoding, then php should output the header: header("Content-Type: text/html; charset=utf-8"), and add , the encoding format of all files is utf-8. Saving as utf-8 may be a bit troublesome. Generally, utf-8 files will have BOM at the beginning. If you use session, there will be problems. You can use editplus to save. In editplus, go to Tools->Parameter Selection->File-> UTF-8 signature, select Always delete, then save to remove the BOM information.
Mysql and PDO Chinese garbled code:
Add after the new PDO connection:
$pdo->query('set names utf8;');
php Chinese garbled code:
a . If you want to use gb2312 encoding, then PHP should output the header: header(“Content-Type: text/html; charset=gb2312”), and add , the encoding format of all files is ANSI, you can open it with Notepad, save as, select the encoding as ANSI, and overwrite the source file.
b. If you want to use utf-8 encoding, then php should output the header: header("Content-Type: text/html; charset=utf-8"), and add , the encoding format of all files is utf-8. Saving as utf-8 may be a bit troublesome. Generally, utf-8 files will have BOM at the beginning. If you use session, there will be problems. You can use editplus to save. In editplus, go to Tools->Parameter Selection->File-> UTF-8 signature, select Always delete, then save to remove the BOM information.
Mysql and PDO Chinese garbled characters:
Add after the new PDO connection:
$pdo->query('set names utf8;');
Related recommendations:
The above is the detailed content of PHP plus xmapp Chinese garbled code. For more information, please follow other related articles on the PHP Chinese website!