PHP系统命令函数使用分析

2015-01-24信息快讯网

本篇文章是对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;
 }
php警告Creating default object from empty value 问题的解决方法
php中stream(流)的用法
php的declare控制符和ticks教程(附示例)
PHP中nowdoc和heredoc使用需要注意的一点
php过滤所有恶意字符(批量过滤post,get敏感数据)
PHP中CURL的CURLOPT_POSTFIELDS参数使用细节
zf框架的registry(注册表)使用示例
php导出excel格式数据问题
php导出word文档与excel电子表格的简单示例代码
详解PHP中strlen和mb_strlen函数的区别
php不使用插件导出excel的简单方法
PHP中is_file不能替代file_exists的理由
Drupal读取Excel并导入数据库实例
php处理restful请求的路由类分享
wordpress自定义url参数实现路由功能的代码示例
使用PHP实现蜘蛛访问日志统计
解析PHP实现下载文件的两种方法
解析:php调用MsSQL存储过程使用内置RETVAL获取过程中的return值
解决PHP mysql_query执行超时(Fatal error: Maximum execution time …)
处理(php-cgi.exe - FastCGI 进程超过了配置的请求超时时限)的问题
解决FastCGI 进程超过了配置的活动超时时限的问题
Smarty foreach控制循环次数的实现详解
解析PHP跳出循环的方法以及continue、break、exit的区别介绍
php获取$_POST同名参数数组的实现介绍
深入解析php中的foreach问题
浅析Apache中RewriteCond规则参数的详细介绍
浅析Dos下运行php.exe,出现没有找到php_mbstring.dll 错误的解决方法
解析curl提交GET,POST,Cookie的简单方法
php setcookie(name, value, expires, path, domain, secure) 参数详解
解析coreseek for sphinx的使用
关于使用coreseek并为其做分页的介绍
Android ProgressBar进度条和ProgressDialog进度框的展示DEMO
coreseek 搜索英文的问题详解
©2014-2024 dbsqp.com