开发者

Looking for an easy explanation of exec in PHP

开发者 https://www.devze.com 2022-12-29 18:00 出处:网络
I am having trouble understanding the exe开发者_运维知识库c function in PHP. Can someone please explain it to me in simple terms?exec — Executes command cmd in the system\'s command interpreter and r

I am having trouble understanding the exe开发者_运维知识库c function in PHP. Can someone please explain it to me in simple terms?


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


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)


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


http://php.net/exec

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

0

精彩评论

暂无评论...
验证码 换一张
取 消