html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

php压缩多个CSS为一个css的代码并缓存-PHPphp技巧 php,CSS,缓存

[ ] 已经帮助:人解决问题
复制代码 代码如下:

<?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();
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助