tags:

views:

70

answers:

4

I am having trouble understanding the exec function in PHP. Can someone please explain it to me in simple terms?

+1  A: 

exec — Executes command cmd in the system's command interpreter and returns the last line of output. Optional arguments allow the command output and return value to be captured.

string exec(cmd[, array_name][, $return_value]); string cmd: Command to be executed

kishore
A: 

http://php.net/exec

(There seems little point in providing any other answer without a more specific question)

David Dorward
A: 

exec will call a program on the pc which runs your script and will return the last line of the output. e.g.

$result = exec('echo bla');
echo $result; // outputs 'bla'

(usually you don't want to use it, and some shared hosting servers do not allow it's usage due to security concerns)

knittl
A: 

i prefer shell_exec http://php.net/manual/en/function.shell-exec.php it returns all output

Osman Üngür