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;
 }

相关文章

php实现购物车功能(以大苹果购物网为例)

php实现购物车功能(以大苹果购物网为例)

首先是几个简单的登录页面 <body> <form action="chuli.php" method="post"> <div style="mar...

php实现扫描二维码根据浏览器类型访问不同下载地址

<?php $Agent = $_SERVER['HTTP_USER_AGENT']; preg_match('/android|iphone/i',$Agent,$m...

PHP创建文件及写入数据(覆盖写入,追加写入)的方法详解

本文实例讲述了PHP创建文件及写入数据(覆盖写入,追加写入)的方法。分享给大家供大家参考,具体如下: 这里主要介绍了PHP创建文件,并向文件中写入数据,覆盖,追加的实现代码,需要的朋友可...

简述php环境搭建与配置

最近在学习PHP,以下是看PHP100视频教程,做的学习笔记,在这里存放以便今后使用。 apache--PHP--DB(mysql) 一、apache:基本工作 ·用户通过浏览器访问服务...

php实现的Timer页面运行时间监测类

本文实例讲述了php实现的Timer页面运行时间监测类及其用法,是一款非常实用的PHP类文件。分享给大家供大家参考。具体分析如下: 该php Timer页面运行时间监测类,可按不同key...