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

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

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

相关文章

Sorting Array Values in PHP(数组排序)

复制代码 代码如下: $full_name = array(); $full_name["Roger"] = "Waters"; $full_name["Richard"] = "Wri...

PHP关联链接常用代码

方法一:手动编辑添加 方法二:使用程序在输出内容时实现,又不影响后台内容的编辑。 下面是PHP自动给文章内容添加关联链接方法和示例: Keylinks函数方法: 参数一:要处理的内容 参...

php加速器eAccelerator的配置参数、API详解

它还能够对脚本进行优化以便加速它们的执行速度。利用eAccelerator可以减少服务器的负载并提高PHP代码的执行时间。 eAccelerator配置选项:复制代码 代码如下:zend...

php开启openssl的方法

php开启openssl的方法,大多数情况下openssl是没有开启的,要想启用需要进行下简单的设置windows下开启方法: 1: 首先检查php.ini中;extension=php...

PHP输出缓存ob系列函数详解

ob的基本原则:如果ob缓存打开,则echo的数据首先放在ob缓存。如果是header信息,直接放在程序缓存。当页面执行到最后,会把ob缓存的数据放到程序缓存,然后依次返回给浏览器。下面...