PHP压缩多个CSS文件的代码

作者: zms! 日期: 2018.04.18 本文发布于711天前 分类: PHP函数语法点滴 相关:

header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
  /* remove comments */
  $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
  /* remove tabs, spaces, newlines, etc. */
  $buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
  return $buffer;
}
/* your css files */
include('master.css');
include('typography.css');
include('grid.css');
include('print.css');
include('handheld.css');
ob_end_flush();

返回上一页


讨论区

您尚未 登录,或请 注册

登 录 注 册


你可能也喜欢

dbMySQL数据源访问类 2020.03.14,7 pv
php计算当前时间到以后一天、一周、一月、一年 2020.01.12,1 pv
php防止CC攻击代码 php防止网页频繁刷新 2019.06.12,7 pv

php将手机号转为字符串并求所有数字之和,或求字符串中所有数字之和的两个方法: 2018.10.15,15 pv
PHP环境加固,让黑客无从下手 2018.05.15,11 pv
PHP支持手势的手机端图片裁剪上传 2018.05.09,9 pv