欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-26 14:18:33
复制代码 代码如下:
复制代码 代码如下:

<?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();

上一篇:

下一篇: