What to do if php cmd prints Chinese garbled characters

藏色散人
Release: 2023-03-13 19:16:02
Original
2074 people have browsed it

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...
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!