PHP系统命令函数使用分析

yipeiwu_com6年前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;
 }

相关文章

phpmailer简单发送邮件的方法(附phpmailer源码下载)

本文实例讲述了phpmailer简单发送邮件的方法。分享给大家供大家参考,具体如下: 首先,点击此处本站下载相应的php文件。 解压后有2个php文件(2个类)  1个html...

PHP中使用Imagick实现各种图片效果实例

imagick是一个功能强大的图像处理库。  说是翻译 其实就是简要介绍imagick 的主要功能的或者说是我觉得比较实用的功能函数的介绍 以及使用的例子。  因...

PHP学习笔记(三):数据类型转换与常量介绍

一、PHP数据类型相互转换 1、强制转换 复制代码 代码如下: // bool,int,float,string,array,object,null bool settype ( mix...

PHP结合JQueryJcrop实现图片裁切实例详解

我们经常可以看到一些网站上有图片剪切的功能,或许你会觉得这一功能炫目华丽,神秘莫测!但是今天介绍的一款专用于图片裁切的插件jquery.Jcrop.min.js就将揭开图片剪切的神秘面纱...

PHP解析RSS的方法

本文实例讲述了PHP解析RSS的方法。分享给大家供大家参考。具体如下: 1. php代码如下:     复制代码 代码如下:<?p...