Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器 软件资源

软件开发小程序制作系统集成与运维空间租用硬件开发视频监控技术咨询与支持——联系电话:0311-88999002/88999003

首页 / 网页编程 / PHP / 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(“ ",$res);
         } elseif(@is_resource($f = @popen($cmd,"r"))) {
             $res = "";
             while(!@feof($f)) {
                 $res .= @fread($f,1024);
             }
             @pclose($f);
         }
     }
     return $res;
 }