首页 > 编程 > PHP > 正文

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

2019-11-22 01:00:36
字体:
来源:转载
供稿:网友
复制代码 代码如下:

<?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();
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表