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.
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!