How to troubleshoot the EXEC () function in PHP without a return value

Source: Internet
Author: User
This article mainly introduces the EXEC () function in PHP no return value of the method of troubleshooting, interested in the friend's reference, I hope to be helpful to everyone.

Installation fails on many servers that need to be used to exec security imagemagic

EXEC () failed to execute the external command, but there is no error message.

EXEC executes a command at the command line without problems, but in PHP there is an error. This issue 99.99% is related to permissions, but the command that exec executes does not return an error. One trick is to use the pipe command, 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);

With 2>&1, the command outputs the error from the execution of the shell to the $output variable, which can be analyzed by outputting the variable.

Note: Exec has 3 parameters, the first is the command to execute, the second is an array, the value of the array is generated after the first command executes, the third parameter executes the state, 0 indicates success, and the others indicate failure.

In PHP There are a total of three functions that can be used to execute external command system,exec,passthru.

The above is the whole content of this article, I hope that everyone's study has helped.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.