信息发布→ 登录 注册 退出

PHP系统命令函数使用分析

发布时间:2026-01-11

点击量:
复制代码 代码如下:
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;
 }
标签:# span  # elseif  # passthru  # shell_exec  # pclose  # return  # popen  # feof  # fread  # execute  # cmd  # nbsp  # PHP  # BR  # function  # ob_start  # ob_get_contents  # ob_end_clean  # res  # function_exists  # system  # PHP执行系统命令函数实例讲解  # 函数  # 系统命令  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!