Atitit. Execute cmd command line PHP
1. Execute the CMD command line and invoke the base of the system command 1
1.1. Actual Execution Mode 1
1.2. Questions about Spaces 1
1.3. Chinese path problem, program file read encoding settings 1
1.4. Echo Garbled 2
2. Exec,system and other functions call system commands 2
3. PHP.ini, turn off safe Mode Safe_mode = Off 3
4. Reference 3
1. Execute the CMD command line and invoke the base of the system command
1.1. Actual execution mode
Processmonitor check. Get..
pid:115372, Command line:cmd.exe/c "D:\workspace to bake? \atibrow\exp_receipt.bat"
1.2. Questions about Spaces
Double Quote Resolution
1.3. Chinese path problem, program file read encoding settings
Default_charset = "Utf-8" in php.ini is just setting the encoding of Post,get and cannot set the read encoding of PHP files. It is best to comment out this parameter, let him according to the encoding of the file itself automatically judge, otherwise the output PHP results are header (' Content-type:text/html;charset=utf8
Author:: Old Wow's paw Attilax Ayron, email:1466519819@qq.com
The reason is that the PHP file itself is encoded using the system character set, Chinese Windows XP is GB2312, each file header has a field to indicate how the file is encoded
When compiling Java source files with Javac, the compiler reads the contents of the source file by default in the system code. If the source file is not saved with system encoding, you can specify the specific encoding with the command javac-encoding
Lymphatic, only not a PHP file encoding set to GBK. Just OK.
1.4. Echo garbled
Header (' CONTENT-TYPE:TEXT/HTML;CHARSET=GBK ');
2. Exec,system and other functions call system commands
These two are all used to invoke the system shell command,
Different points:
Exec can return all execution results to the $output function (array), $status is the execution status 0 for success 1 for failure
Systerm does not need to provide the $output function, he is directly returning the result, the same $return_var is the execution of the status code 0 for the success of 1 for the failure
exec Example:
1. The following is the reference content:
2.
3. $a = Exec ("dir", $out, $status);
4. Print_r ($a);
5. Print_r ($out);
6. Print_r ($status);
7.?>
System Example:
1. The following is the reference content:
2.
3. $a = System ("dir", $out);
4. Print_r ($a);
5. Print_r ($out);
6.?>
3. PHP.ini, turn off safe mode Safe_mode = Off
First, turn on php.ini, turn off safe mode Safe_mode = off, and then look at the list of disabled functions disable_functions = Proc_open, Popen, exec, System, shell_exec, remove exec.
4. Reference
PHP uses functions such as Exec,system to call system commands. htm
Apache and PHP default encoding problem Resolution (detailed) _php Chase _ Sina blog. htm
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.