php压缩多个CSS为一个css的代码并缓存

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

<?php
/*
Compress multiple CSS files into one and cache for an hour.

Use the same code for Javascript, but replace below "text/css" with "text/javascript" and of course make sure you include .js files instead of .css ones.
*/
ob_start("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");    
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 60*60)." GMT");

include('somefile.css');
echo "\n\n";
include('anotherfile.css');
echo "\n\n";

ob_flush();

相关文章

PHP实现的各类hash算法长度及性能测试实例

本文实例讲述了PHP实现的各类hash算法长度及性能测试。分享给大家供大家参考,具体如下: Hash结果如下 <?php $data = "hello world";...

php强制下载类型的实现代码

复制代码 代码如下: function downloadFile($file){ /*Coded by Alessio Delmonti*/       &...

php中final关键字用法分析

本文实例讲述了php中final关键字用法。分享给大家供大家参考,具体如下: final关键字只能用来定义类和定义方法。 使用final关键字标记的类不能被继承 final clas...

PHP基于timestamp和nonce实现的防止重放攻击方案分析

本文实例讲述了PHP基于timestamp和nonce实现的防止重放攻击方案。分享给大家供大家参考,具体如下: 以前总是通过timestamp来防止重放攻击,但是这样并不能保证每次请求都...

PHP自动加载机制实例详解

本文实例讲述了PHP自动加载机制。分享给大家供大家参考,具体如下: 在php中,我们一般使用 require, requre_once, include, include_once 这四...