PHP系统命令函数使用分析_php教程-查字典教程网
PHP系统命令函数使用分析
PHP系统命令函数使用分析
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:functionexecute($cmd){$res='';if($cmd){if(function_exists('sy...

复制代码 代码如下:

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;

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类