zoukankan      html  css  js  c++  java
  • PHP 系统命令函数

     1 function execute($cmd) {
     2     $res = '';
     3     if ($cmd) {
     4         if(function_exists('system')) {
     5             @ob_start();
     6             @system($cmd);
     7             $res = @ob_get_contents();
     8             @ob_end_clean();
     9         } elseif(function_exists('passthru')) {
    10             @ob_start();
    11             @passthru($cmd);
    12             $res = @ob_get_contents();
    13             @ob_end_clean();
    14         } elseif(function_exists('shell_exec')) {
    15             $res = @shell_exec($cmd);
    16         } elseif(function_exists('exec')) {
    17             @exec($cmd,$res);
    18             $res = join(“
    ",$res);
    19         } elseif(@is_resource($f = @popen($cmd,"r"))) {
    20             $res = '';
    21             while(!@feof($f)) {
    22                 $res .= @fread($f,1024);
    23             }
    24             @pclose($f);
    25         }
    26     }
    27     return $res;
    28 }
  • 相关阅读:
    8.5
    8.12
    8.11
    8.14
    8.15
    8.18
    8.16
    8.20
    Android新版NDK环境配置(免Cygwin)
    在Windows7上搭建Cocos2d-x win32开发环境
  • 原文地址:https://www.cnblogs.com/liangle/p/3172251.html
Copyright © 2011-2022 走看看