Shell Commands

This section describes functions that interact with the command shell in some way. Some of them execute other programs, and two of them read or write to environment variables.

string exec(string command, array output, integer return)

The exec function attempts to execute the command argument as if you had typed it in command shell. Nothing is echoed to the browser, but the last line of output from the execution is returned. If the optional output argument is supplied, each line of output will be added to the output argument as an array element. If the optional return argument is supplied, the variable is set to the return value of the command.

It is very dangerous to put any user-supplied information inside the command argument. ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.