时时商务社区

标题: PHP系统命令函数使用分析 [打印本页]

作者: 阿情    时间: 2018-2-14 08:15

            [U]复制代码[/U] 代码如下:
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执行linux系统命令的常用函数使用说明
  • php中使用exec,system等函数调用系统命令的方法(不建议使用,可导致安全问题)
  • php模拟ping命令(php exec函数的使用方法)
  • PHP启动windows应用程序、执行bat批处理、执行cmd命令的方法(exec、system函数详解)
  • PHP执行linux命令常用函数汇总
  • 利用PHP命令行模式采集股票趋势信息
  • php通过执行CutyCapt命令实现网页截图的方法
  • php  redis扩展支持scan命令实现方法
  • php外部执行命令函数用法小结
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2