12.3.Http工具类

Http工具类

报头工具

use qing\http\Header;

Header::content_type('text/html','utf-8');
Header::content_type('application/javascript','utf-8');
Header::status(404);

//
class Header{
    /**
     * 内容类型报头
     * application/javascript
     * 
     * @param string $type
     * @param string $charset
     */
    public static function content_type($type="text/html",$charset="utf-8"){
        header("Content-type:{$type};charset={$charset}");
    }
    /**
     * 编码报头
     * 
     * @param string $type
     */
    public static function utf8($type="text/html"){
        self::content_type($type);
    }
    /**
     * 发送状态码200,302,404
     *
     * @param integer $statusCode 404/302
     */
    public static function status($statusCode){}
}

缓存报头

use qing\http\Cache;
//开启缓存
Cache::on();
//关闭缓存
Cache::off();