Home  >  Article  >  Backend Development  >  How to solve the problem that php exec Chinese does not execute

How to solve the problem that php exec Chinese does not execute

藏色散人
藏色散人Original
2021-11-04 09:07:201794browse

Solution for php exec not executing in Chinese: 1. Set the language of the environment through "$set_charset = 'export.UTF-8;';"; 2. Execute "exec($set_charset.$cmd, $ ret, $out);" That's it.

How to solve the problem that php exec Chinese does not execute

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

How to solve the problem that php exec cannot work in Chinese Execution problem?

The pitfalls of PHP calling exec to execute Chinese commands:

Server system Linux

Execute rar x through php exec. The decompression command maintains the directory structure and compresses the package. The English directory is decompressed normally

The Chinese directory decompression failed, is there any way to solve it

There is no problem in decompressing it directly using the terminal command

Final solution

$set_charset = 'export.UTF-8;';
exec($set_charset.$cmd, $ret, $out);

Before executing the command, set the language setting of the environment to solve the problem

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to solve the problem that php exec Chinese does not execute. 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