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
One technique is to use the pipe command, which uses 2>&1, and the command outputs the error of the shell execution to the $output variable, which can be parsed.
Such as:
EXEC (' Convert a.jpg b.jpg ', $output, $return _val);
Switch
EXEC (' Convert a.jpg b.jpg 2>&1 ', $output, $return _val);
Print_r ($output);
Example:
Running on Win2003 with exec executing the Java Parsing command has been unsuccessful:
C:\progra~1\java\jdk1.8.0_73\bin\java.exe-jar C:\p\java\test.jar
After the command was appended 2>&1, the magic succeeded.
EXEC ("C:\progra~1\java\jdk1.8.0_73\bin\java.exe-jar C:\p\java\test.jar 2>&1", $output, $return _val);
The above describes the PHP exec usage details, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.