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中使用foreach()遍历二维数组的简单实例

第一种类型 想用foreach()遍历整个二维数组: $team = array('lk','ok'); $book = array('linux服务器配置与管理',$team)...

php中文本操作的类

给大家一个简单的文本操作的类  我以前写的,不过一直都没机会用了,文本不如数据库 数据是以行保存的,以\n结尾,注意你输入的数据必须以"\n"结尾的,这是几个最基本的类成员,文...

PHP基于CURL发送JSON格式字符串的方法示例

本文实例讲述了PHP基于CURL发送JSON格式字符串的方法。分享给大家供大家参考,具体如下: /* * post 发送JSON 格式数据 * @param $url string...

php魔术方法与魔术变量、内置方法与内置变量的深入分析

php内置变量了:DIRECTORY_SEPARATORDIRECTORY_SEPARATOR是一个返回跟操作系统相关的路径分隔符的php内置命令,在windows上返回/,而在linu...

php fsockopen伪造post与get方法的详解

fsockopen 伪造 post和get方法哦,如果你正在找 伪造 post和get方法的php处理代码这款不错哦。复制代码 代码如下:<?php//fsocket模拟post提...