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

yipeiwu_com6年前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基于工厂模式实现的计算器实例

本文实例讲述了PHP基于工厂模式实现的计算器。分享给大家供大家参考。具体如下: abstract class Calculator { private $number1; pr...

php5.2.0内存管理改进

php5.2.0的内存管理做了较大的改进,某些情况下内存不能释放的问题不存在了。测试php脚本(mem.php),我用echo N>>和sleep来控制脚本在某个阶...

PHP开启opcache提升代码性能

配置指令如下: [opcache] zend_extension=opcache.so opcache.enable_cli=1 ;共享内存大小, 这个根据你们的需求可调 opcac...

php实现的双向队列类实例

本文实例讲述了php实现的双向队列类及其用法,对于PHP数据结构与算法的学习有不错的参考价值。分享给大家供大家参考。具体分析如下: (deque,全名double-ended queue...

PHP使用内置dir类实现目录遍历删除

本文实例讲述了PHP使用内置dir类实现目录遍历删除的方法。分享给大家供大家参考。具体实现方法如下: function clearDir($dir) { if (file_exis...