PHP EXEC Usage Detailed

Source: Internet
Author: User
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.

  • 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.