当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP系统命令函数使用分析

PHP系统命令函数使用分析

2019年04月07日  | 移动技术网IT编程  | 我要评论

公司制企业,师傅经,ca1142航班

复制代码 代码如下:

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;
 }

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网