PHP系统命令函数使用分析
更新时间:2013年07月05日 08:55:39 作者:
本篇文章是对PHP中系统命令函数的使用进行了详细的分析介绍,需要的朋友参考下
复制代码 代码如下:
function execute($cmd) {
$res = '';
if ($cmd) {
if(function_exists('system')) {
@ob_start();
@system($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cmd);
} elseif(function_exists('exec')) {
@exec($cmd,$res);
$res = join(“\n",$res);
} elseif(@is_resource($f = @popen($cmd,"r"))) {
$res = '';
while(!@feof($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}
您可能感兴趣的文章:
相关文章
PHP5.3连接Oracle客户端及PDO_OCI模块的安装方法
这篇文章主要介绍了PHP5.3连接Oracle客户端及PDO_OCI模块的安装方法,结合实例形式详细分析了php5.3环境下PDO_OCI模块的安装方法,并给出了连接Oracle测试程序,需要的朋友可以参考下2016-05-05
Apache实现Web Server负载均衡详解(不考虑Session版)
本篇文章是对使用Apache实现Web Server负载均衡的方法进行了详细的分析介绍,需要的朋友参考下(不考虑Session版)2013-07-07


最新评论