Solution to Chinese garbled characters in php cli: 1. Open the php.ini file, and then set the character set to "default_charset = "UTF-8""; 2. Set the cmd window to utf-8 encoding.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Solution to Chinese garbled characters in php cli mode Method
1. php.ini default character set: default_charset = "UTF-8"
2. Set the cmd window to utf-8 encoding.
The solution is as follows:
1. Operation: Press "win R" at the same time and enter regedit to enter the registry
2. Find HKEY_CURRENT_USER\Console\% SystemRoot%_system32_cmd.exe, if a CodePage item already exists under this item, change the value to decimal "65001" and click OK; if it does not exist, create a new DWORD (32-bit value) under this item and name it " CodePage" and the value is set to "65001". Then close the registry manager.
3. At this time, close all cmd windows and restart cmd to take effect.
Recommended learning: "PHP Video Tutorial"
3. Directly echo the php file
<?php echo "中国";
Open cmd, enter chcp 65001 and press Enter
mysqli_set_charset($conn,'utf8');
The above is the detailed content of What to do if php cli has Chinese garbled characters?. For more information, please follow other related articles on the PHP Chinese website!