Home>Article>Backend Development> What to do if php cli has Chinese garbled characters?

What to do if php cli has Chinese garbled characters?

藏色散人
藏色散人 Original
2021-05-13 09:21:48 2352browse

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.

What to do if php cli has Chinese garbled characters?

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


      

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:rdkafka php how to install Next article:rdkafka php how to install