How PHP executes the cmd command
Description
This section is implemented in the context of the WAMP package installation.
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.
PHP Code:
??
Executing the PHP file, you will find a test folder under the D drive.
Reference Documentation:
exec function parsing
EXEC syntax: string exec (String command, string [array], int [return_var]);
EXEC return value:? string
EXEC parameter description
command– commands to execute
array–? is the output value
The return_var– is a return value of 0 or 1, and if return 0 succeeds, the execution fails with return of 1.
exec unsuccessful, debug scenario
Skill Sharing:
With the pipe command, using 2>&1, the command outputs the error of the shell execution to the $output variable, which can be analyzed by outputting the variable.
For example:
EXEC (' Convert a.jpg b.jpg ', $output, $return _val);
?
Modified to:
EXEC (' Convert a.jpg b.jpg 2>&1′, $output, $return _val);p rint_r ($output);
?
?