• 技术文章 >php教程 >php手册

    PHP系统命令函数使用分析

    2016-06-13 11:43:17原创534
    复制代码 代码如下:


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

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:解析PHP实现下载文件的两种方法 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • PHP弹出提示框并跳转到新页面即重定向到新页面• 利用PHP实现智能文件类型检测的实现代码• PHP 页面跳转到另一个页面的多种方法方法总结• 我的论坛源代码(五)• 建立文件交换功能的脚本(二)
    1/1

    PHP中文网