php 执行命令操作

2019-02-23  本文已影响0人  空气KQ

exec — 执行一个外部程序

exec ( string $command [, array &$output [, int &$return_var ]] ) : string

passthru — 执行外部程序并且显示原始输出

passthru ( string $command [, int &$return_var ] ) : void

system — 执行外部程序,并且显示输出

system ( string $command [, int &$return_var ] ) : string
command
要执行的命令。
return_var
如果提供 return_var 参数, 则外部命令执行后的返回状态将会被设置到此变量中。
返回值
成功则返回命令输出的最后一行, 失败则返回 FALSE

shell_exec — 通过 shell 环境执行命令,并且将完整的输出以字符串的方式返回。

shell_exec ( string $cmd ) : string
参数
cmd
要执行的命令。

返回值
命令执行的输出。 如果执行过程中发生错误或者进程不产生输出,则返回 NULL。

<?php
$output = shell_exec('ls -l');
echo "<pre>$output</pre>";
?>
total 4
-rw-r--r-- 1 www www 66 Feb 23 12:08 index.php
上一篇 下一篇

猜你喜欢

热点阅读