This paper analyzes the solution of the Chinese filtering in PHP when using Escapeshellarg. Share to everyone for your reference. Specifically as follows:
First, the question:
The same code, found through localhost/index.php access, and in the shell through PHP./index.php run the results are different.
A Linux program needs to be executed by Shell_exec in the program, and its input comes from Echo, which is:
Second, the solution:
And this $str may contain Chinese. At first I thought it was some_cmd himself to filter out Chinese, and later found that it was escapeshellarg problem.
Seemingly appear this problem is not much, after the query and test found that the shell and the Apache PHP-CGI operating environment caused by different.
Add in PHP:
SetLocale (Lc_ctype, "UTF8", "en_US.") UTF-8 ");
It's normal!
I hope this article will help you with the PHP program design.