码迷,mamicode.com
首页 > Web开发 > 详细

PHP实用函数整理(1)

时间:2017-12-05 15:56:56      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:mdi   turn   ==   $path   nocache   continue   header   false   ade   

/**
 * 清空整个目录
 * @param 目录 $path
 */
function clear_dir($path) {
    $op = dir($path);
    while(false != ($item = $op->read())) {
        if($item == ‘.‘ || $item == ‘..‘) continue;
        
        if(is_dir($op->path.‘/‘.$item)) {
            clear_dir($op->path.‘/‘.$item);
            rmdir($op->path.‘/‘.$item);
        } else {
            unlink($op->path.‘/‘.$item);
        }
    }
}

  

/**
 * 取消网页缓存
 */
function header_nocache() {
    header("Cache-Control: no-cache");
    header("Pragma: no-cache");
    header("Expires: 0");
}

  

/**
 * 是否已GET方式访问
 * @return boolean
 */
function is_get() {
    return $_SERVER[‘REQUEST_METHOD‘] == "GET";
}

/**
 * 是否已POST形式访问
 * @return boolean
 */
function is_post() {
    return $_SERVER[‘REQUEST_METHOD‘] == "GET";
}

  

PHP实用函数整理(1)

标签:mdi   turn   ==   $path   nocache   continue   header   false   ade   

原文地址:http://www.cnblogs.com/hatsusakana/p/7987266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!