Program execution function library: exec

Source: Internet
Author: User
Keywords exec php Chinese function Manual program execution function library
Tags aliyun array external external program function function library html http

exec

(PHP3, PHP4)

EXEC---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Executing an external program

Syntax: string exec (String command [, string array [, int return_var]])

Description:

EXEC () executes the command commands given, but it does not output anything, it simply returns the last line from the result of the command, and if you need to execute a command and get all the data from the command, you can use the PassThru () function.

If a parameter array is given, the specified array is filled with each row that the command outputs. Note: If the array has previously contained elements, EXEC () will append it to the array, if you do not want the function to append elements, you can pass this array to exec () Call Unset () before.

If a parameter array and Return_var are given, the state command to return execution will be written to this variable.

Note: If you allow data from user input to be passed to this function, you should use Escapeshellcmd () to determine that this user cannot spoof (trick) the system to execute arbitrary (arbitrary) commands.

Note: If you use this function to start a program and you want to leave it in the background (background), you must make sure that the output of the program is turned (redirected) to a file or some output stream, otherwise PHP will hang (hang) Until the program execution is finished.

Reference: System () PassThru () Popen () Escapeshellcmd ()

Related Article

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.