加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP系统命令函数使用解析

发布时间:2022-07-24 09:06:27 所属栏目:PHP教程 来源:互联网
导读:本篇文章是对PHP中系统命令函数的使用进行了详细的分析介绍,需要的朋友参考下 复制代码 代码如下: function execute($cmd) { $res = ; if ($cmd) { if(function_exists(system)) { @ob_start(); @system($cmd); $res = @ob_get_contents(); @ob_end_clean
    本篇文章是对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;
 
 }。
 

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读