The following editor will bring you a brief discussion of PHP's exec()functionNo return value troubleshooting method (must read). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
In securityimagemagic, exec needs to be used on many serversInstallationfailed
exec() executes externally The command failed without any error message.
exec executes a certain command without any problem on the command line, but an error occurs in php. This problem is 99.99% related to permissions, but the command executed by exec will not return an error. One trick is to use pipe commands, assuming your exec call is as follows:
exec('convert a.jpg b.jpg', $output, $return_val);
can be changed as follows:
exec('convert a.jpg b.jpg 2>&1', $output, $return_val); print_r($output);
Use 2>&1, the command will output the error during shell execution to the $output variable, and output the variable for analysis.
Remarks: exec has 3 parameters. The first one is the command to be executed. The second parameter is an array. The value of the array is generated after the first command is executed. , The status of the third parameter execution, 0 indicates success, and the others indicate failure.
There are three functions in php that can be used to execute external commands system, exec, and passthru.
The above is the detailed content of Briefly introduce the troubleshooting method for PHP's exec() function without return value (recommended). For more information, please follow other related articles on the PHP Chinese website!