Home >Backend Development >PHP Problem >What to do if php cmd prints Chinese garbled characters

What to do if php cmd prints Chinese garbled characters

藏色散人
藏色散人Original
2021-11-10 09:19:522179browse

php cmd solution to print Chinese garbled characters: 1. Create a php script; 2. Execute the cmd command in the script to modify the current page number character set.

What to do if php cmd prints Chinese garbled characters

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php cmd prints Chinese garbled characters What should I do?

Using the command line to execute the php script outputs garbled characters

Today, when I execute the php script in cmd or shellpower on the Windows platform, the Chinese output will be garbled .

Finally I thought of a solution, which is to execute the cmd command in the php script to modify the current page number character set

<?php
exec("CHCP 65001");
// coding...

If other encodings are based on Change the ones below yourself!

chcp 65001 is to change to UTF-8

chcp 936 can be changed back to the default GBK

chcp 437 is American English

Recommended learning: "PHP video tutorial

The above is the detailed content of What to do if php cmd prints 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