Home > Backend Development > PHP Problem > What should I do if php exec does not return a value?

What should I do if php exec does not return a value?

藏色散人
Release: 2023-03-10 12:14:02
Original
3460 people have browsed it

The solution to php exec not returning a value: first find the exec calling code; then modify the statement to "exec('convert a.jpg b.jpg 2>&1', $output, $return_val);" that is Can.

What should I do if php exec does not return a value?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What should I do if php exec does not return a value?

Troubleshooting method for PHP's exec() function to have no return value

In order to secure imagemagic, exec needs to be used and the installation fails on many servers

exec() fails to execute external commands. But there is no error message.

There is no problem when exec executes a certain command 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 a pipeline command. Suppose your exec call is as follows:

exec('convert a.jpg b.jpg', $output, $return_val);
Copy after login

can be changed as follows:

exec('convert a.jpg b.jpg 2>&1', $output, $return_val);    
print_r($output);
Copy after login

Use 2>&1, the command will output the error during shell execution to the $output variable , output this variable to analyze.

Note: exec has 3 parameters. The first 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 execution status of the third parameter, 0 indicates success, others indicate failure.

There are three functions in php that can be used to execute external commands system, exec, and passthru

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if php exec does not return a value?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template