当前位置:首页 > PHP教程 > PHP高级教程

php压缩多个CSS为一个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 "nn";
include('anotherfile.css');
echo "nn";

ob_flush();

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!