php压缩多个CSS为一个css的代码并缓存
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:
复制代码 代码如下:
<?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();