亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發(fā) > CSS > 正文

php實(shí)現(xiàn)壓縮多個(gè)CSS與JS文件的方法

2020-03-22 17:32:24
字體:
供稿:網(wǎng)友
本文實(shí)例講述了php實(shí)現(xiàn)壓縮多個(gè)CSS與JS文件的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:1. 壓縮css復(fù)制代碼 代碼如下: 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('galleria.css');
include('articles.css');

ob_end_flush();
使用方法如下:
復(fù)制代碼 代碼如下: link href="compress.php" rel="stylesheet" type="text/css" / span id="tester" test /span 2. 壓縮js,利用jsmin類:本實(shí)例源自:http://code.google.com/p/minify/
復(fù)制代碼 代碼如下:header('Content-type: text/javascript');
require 'jsmin.php';
echo JSMin::minify(file_get_contents('common.js') . file_get_contents('common2.js'));其中jsmin.php文件如下:復(fù)制代碼 代碼如下:
php
/**
* jsmin.php - PHP implementation of Douglas Crockford's JSMin.
*
* This is pretty much a direct port of jsmin.c to PHP with just a few
* PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
* outputs to stdout, this library accepts a string as input and returns another
* string as output.
*
* PHP 5 or higher is required.
*
* Permission is hereby granted to use this version of the library under the
* same terms as jsmin.c, which has the following license:
*
* --
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* The Software shall be used for Good, not Evil.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* --
*
* @package JSMin
* @author Ryan Grove ryan@wonko.com
* @copyright 2002 Douglas Crockford douglas@crockford.com (jsmin.c)
* @copyright 2008 Ryan Grove ryan@wonko.com (PHP port)
* @copyright 2012 Adam Goforth aag@adamgoforth.com (Updates)
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version 1.1.2 (2012-05-01)
* @link http://github.com/rgrove/jsmin-php
*/
html' target='_blank'>class JSMin {
const ORD_LF = 10;
const ORD_SPACE = 32;
const ACTION_KEEP_A = 1;
const ACTION_DELETE_A = 2;
const ACTION_DELETE_A_B = 3;
protected $a = '';
protected $b = '';
protected $input = '';
protected $inputIndex = 0;
protected $inputLength = 0;
protected $lookAhead = null;
protected $output = '';
// -- Public Static Methods --------------------------------------------------
/**
* Minify Javascript
*
* @uses __construct()
* @uses min()
* @param string $js Javascript to be minified
* @return string
*/
public static function minify($js) {
$jsmin = new JSMin($js);
return $jsmin- min();
}
// -- Public Instance Methods ------------------------------------------------
/**
* Constructor
*
* @param string $input Javascript to be minified
*/
public function __construct($input) {
$this- input = str_replace("/r/n", "/n", $input);
$this- inputLength = strlen($this- input);
}
// -- Protected Instance Methods ---------------------------------------------
/**
* Action -- do something! What to do is determined by the $command argument.
*
* action treats a string as a single character. Wow!
* action recognizes a regular expression if it is preceded by ( or , or =.
*
* @uses next()
* @uses get()
* @throws JSMinException If parser errors are found:
* - Unterminated string literal
* - Unterminated regular expression set in regex literal
* - Unterminated regular expression literal
* @param int $command One of class constants:
* ACTION_KEEP_A Output A. Copy B to A. Get the next B.
* ACTION_DELETE_A Copy B to A. Get the next B. (Delete A).
* ACTION_DELETE_A_B Get the next B. (Delete B).
*/
protected function action($command) {
switch($command) {
case self::ACTION_KEEP_A:
$this- output .= $this-
case self::ACTION_DELETE_A:
$this- a = $this-
if ($this- a === "'" || $this- a === '"') {
for (;;) {
$this- output .= $this-
$this- a = $this- get();
if ($this- a === $this- b) {
break;
}
if (ord($this- a) = self::ORD_LF) {
throw new JSMinException('Unterminated string literal.');
}
if ($this- a === '//') {
$this- output .= $this-
$this- a = $this- get();
}
}
}
case self::ACTION_DELETE_A_B:
$this- b = $this- next();
if ($this- b === '/' && (
$this- a === '(' || $this- a === ',' || $this- a === '=' ||
$this- a === ':' || $this- a === '[' || $this- a === '!' ||
$this- a === '&' || $this- a === '|' || $this- a === ' ' ||
$this- a === '{' || $this- a === '}' || $this- a === ';' ||
$this- a === "/n" )) {
$this- output .= $this- a . $this-
for (;;) {
$this- a = $this- get();
if ($this- a === '[') {
/*
inside a regex [...] set, which MAY contain a '/' itself. Example: mootools Form.Validator near line 460:
return Form.Validator.getValidator('IsEmpty').test(element) || (/^( :[a-z0-9!#$%&'*+/= ^_`{|}~-]/. ){0,63}[a-z0-9!#$%&'*+/= ^_`{|}~-]@( :( :[a-z0-9]( :[a-z0-9-]{0,61}[a-z0-9]) /.)*[a-z0-9]( :[a-z0-9-]{0,61}[a-z0-9]) |/[( :( :25[0-5]|2[0-4][0-9]|[01] [0-9][0-9] )/.){3}( :25[0-5]|2[0-4][0-9]|[01] [0-9][0-9] )/])$/i).test(element.get('value'));
*/
for (;;) {
$this- output .= $this-
$this- a = $this- get();
if ($this- a === ']') {
break;
} elseif ($this- a === '//') {
$this- output .= $this-
$this- a = $this- get();
} elseif (ord($this- a) = self::ORD_LF) {
throw new JSMinException('Unterminated regular expression set in regex literal.');
}
}
} elseif ($this- a === '/') {
break;
} elseif ($this- a === '//') {
$this- output .= $this-
$this- a = $this- get();
} elseif (ord($this- a) = self::ORD_LF) {
throw new JSMinException('Unterminated regular expression literal.');
}
$this- output .= $this-
}
$this- b = $this- next();
}
}
}
/**
* Get next char. Convert ctrl char to space.
*
* @return string|null
*/
protected function get() {
$c = $this- lookAhead;
$this- lookAhead = null;
if ($c === null) {
if ($this- inputIndex $this- inputLength) {
$c = substr($this- input, $this- inputIndex, 1);
$this- inputIndex += 1;
} else {
$c = null;
}
}
if ($c === "/r") {
return "/n";
}
if ($c === null || $c === "/n" || ord($c) = self::ORD_SPACE) {
return $c;
}
return ' ';
}
/**
* Is $c a letter, digit, underscore, dollar sign, or non-ASCII character.
*
* @return bool
*/
protected function isAlphaNum($c) {
return ord($c) 126 || $c === '//' || preg_match('/^[/w/$]$/', $c) === 1;
}
/**
* Perform minification, return result
*
* @uses action()
* @uses isAlphaNum()
* @uses get()
* @uses peek()
* @return string
*/
protected function min() {
if (0 == strncmp($this- peek(), "/xef", 1)) {
$this- get();
$this- get();
$this- get();
}
$this- a = "/n";
$this- action(self::ACTION_DELETE_A_B);
while ($this- a !== null) {
switch ($this- a) {
case ' ':
if ($this- isAlphaNum($this- b)) {
$this- action(self::ACTION_KEEP_A);
} else {
$this- action(self::ACTION_DELETE_A);
}
break;
case "/n":
switch ($this- b) {
case '{':
case '[':
case '(':
case '+':
case '-':
case '!':
case '~':
$this- action(self::ACTION_KEEP_A);
break;
case ' ':
$this- action(self::ACTION_DELETE_A_B);
break;
default:
if ($this- isAlphaNum($this- b)) {
$this- action(self::ACTION_KEEP_A);
}
else {
$this- action(self::ACTION_DELETE_A);
}
}
break;
default:
switch ($this- b) {
case ' ':
if ($this- isAlphaNum($this- a)) {
$this- action(self::ACTION_KEEP_A);
break;
}
$this- action(self::ACTION_DELETE_A_B);
break;
case "/n":
switch ($this- a) {
case '}':
case ']':
case ')':
case '+':
case '-':
case '"':
case "'":
$this- action(self::ACTION_KEEP_A);
break;
default:
if ($this- isAlphaNum($this- a)) {
$this- action(self::ACTION_KEEP_A);
}
else {
$this- action(self::ACTION_DELETE_A_B);
}
}
break;
default:
$this- action(self::ACTION_KEEP_A);
break;
}
}
}
return $this- output;
}
/**
* Get the next character, skipping over comments. peek() is used to see
* if a '/' is followed by a '/' or '*'.
*
* @uses get()
* @uses peek()
* @throws JSMinException On unterminated comment.
* @return string
*/
protected function next() {
$c = $this- get();
if ($c === '/') {
switch($this- peek()) {
case '/':
for (;;) {
$c = $this- get();
if (ord($c) = self::ORD_LF) {
return $c;
}
}
case '*':
$this- get();
for (;;) {
switch($this- get()) {
case '*':
if ($this- peek() === '/') {
$this- get();
return ' ';
}
break;
case null:
throw new JSMinException('Unterminated comment.');
}
}
default:
return $c;
}
}
return $c;
}
/**
* Get next char. If is ctrl character, translate to a space or newline.
*
* @uses get()
* @return string|null
*/
protected function peek() {
$this- lookAhead = $this- get();
return $this- lookAhead;
}
}
// -- Exceptions ---------------------------------------------------------------
class JSMinException extends Exception {}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。PHP教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
国产男女无遮挡猛进猛出| 欧洲精品一区二区三区在线观看| 国产私人尤物无码不卡| 亚洲人成在线播放| 同性恋视频一区| 牲欧美videos精品| 久久av免费看| 日韩精品综合一本久道在线视频| 精品一区二区三区四| 国产精品理论片| 日韩专区欧美专区| 艳妇乳肉豪妇荡乳av| 国产综合免费视频| www.国产毛片| 欧美xxxx黑人又粗又长| 免费cad大片在线观看| 欧美家庭影院| 久久久婷婷一区二区三区不卡| 国产成人综合一区二区三区| 国产日韩中文在线| 欧美黄色三级网站| 9999精品成人免费毛片在线看| 精品欧美一区二区三区久久久| 亚洲 日韩 国产第一区| 黄色av免费网站| 黑人精品一区二区| 天海翼亚洲一区二区三区| 亚洲综合五月天婷婷丁香| 久久久久久亚洲中文字幕无码| 三区四区电影在线观看| 国产在线视频精品视频免费看| 91精品国产福利| 色狼人综合干| 欧美精品黄色| 亚洲天堂网站在线观看视频| 中文字幕在线第一页| jizzjizz亚洲中国少妇| 日本韩国一区二区| 少妇性bbb搡bbb爽爽爽欧美| 4k岛国日韩精品**专区| 日韩精品中文字幕在线观看| 蜜桃91麻豆精品一二三区| 看av免费毛片手机播放| 久久色在线视频| 国产欧美一区二区三区鸳鸯浴| 亚洲第一区视频| 日本黄区免费视频观看| 国产欧美日韩专区| 91po在线观看91精品国产性色| 国产黄色录像片| 超碰96在线| 日韩精品免费一区二区在线观看| 欧美精品 - 色网| 老司机深夜福利在线观看| 欧美一区二区不卡视频| 日韩精品极品在线观看| 国产视频一区二区三区在线观看| 欧亚精品一区| 国产精品亚洲一区二区三区在线| 奇米影视首页 狠狠色丁香婷婷久久综合| 成人亚洲精品777777ww| 一区二区三区在线视频观看| 国产三区视频在线观看| 岳乳丰满一区二区三区| 奇米影视狠888| 欧美肉体xxxx裸体137大胆| eeuss影院www免费视频| 国产精品亚洲欧美| www.51色.com| 四虎wwwcom| 欧美美女操人视频| 97在线中文字幕| jizzz18| 欧美高清电影在线看| 日本一区二区网站| 成人综合日日夜夜| 国产+成+人+亚洲欧洲在线| 亚洲二区在线视频| 日韩偷拍一区二区| 色狮一区二区三区四区视频| 国产视频二区| 日韩av免费| 亚洲午夜久久久久久久| 亚洲国产欧美一区二区三区久久| 国产精品视频分类| 日韩精品三区四区| 性娇小13――14欧美| 一区二区三区美女xx视频| 日韩精品手机在线| 日韩午夜在线观看视频| 国产成人涩涩涩视频在线观看| 亚洲国产综合一区| 成人精品一区二区三区电影免费| 中文字幕一区二区三区免费看| 日韩禁在线播放| 公共露出暴露狂另类av| 狠狠色丁香婷婷综合| 国产欧美日韩在线播放| 欧美日溪乱毛片| 色噜噜一区二区| 台湾佬中文娱乐网欧美电影| 一区二区三区少妇| 国产又粗又长又大的视频| 懂色一区二区三区免费观看| 欧美自拍视频在线观看| 麻豆一区二区三区| 波多野结衣视频在线看| 豆国产96在线|亚洲| 国产在线视精品麻豆| 亚洲国产毛片完整版| 中文字幕av一区中文字幕天堂| 欧美日韩免费看| 国产精品一区而去| 日本亚洲欧美天堂免费| 一区二区在线免费观看| 成人性生交大片免费看网站| 影音先锋男人看片资源| 在线观看成人免费视频| 国产精品三上| 日韩av在线播放资源| 欧美色图激情小说| 国产一区二区精品久久91| 国产少妇在线观看| 亚洲成人福利视频| a毛片在线播放| 久久精品国产网站| 欧美区视频在线观看| 色偷偷网友自拍| 高清日韩欧美| 亚洲福利视频免费观看| 久久91精品国产91久久久| 精品伊人久久97| 成人av资源电影网站| 日韩av中文字幕在线免费观看| 国产丝袜护土调教在线视频| 91年精品国产| 盗摄系列偷拍视频精品tp| 无码精品国产一区二区三区免费| 成人影院在线免费观看| 免费观看的毛片| 婷婷综合网站| 粉嫩欧美一区二区三区高清影视| 国产成人亚洲精品无码h在线| 8av国产精品爽爽ⅴa在线观看| 国产精品免费视频xxxx| 久久精品国产免费看久久精品| 黑人极品videos精品欧美裸| 久久九九国产视频| 精品欧美一区二区精品少妇| 男女啪啪网站| 日韩欧美成人一区二区三区| 国产精品女主播在线观看| 91美女片黄在线观看游戏| 男生和女生一起差差差视频| 男人在线视频资源| 91成人在线视频| 亚洲最大的黄色网| 中文字幕一区二区人妻在线不卡| 久久香蕉精品| 国产91ⅴ在线精品免费观看| 国产.欧美.日韩| 国产aⅴ综合色| 精品无码一区二区三区电影桃花| 激情乱色小说视频| 国产日韩欧美视频在线观看| 成人网页在线免费观看| 亚洲国产精品久久久久| 日本乱人伦一区| 日韩08精品| 国产毛片久久| 日韩xxxxxxxxx| 国产美女久久精品香蕉69| 国产精品第五页| 福利一区视频| 国产免费中文字幕| 欧美久久久久久久久久久久| 亚洲AV无码久久精品国产一区| 国产真人做爰毛片视频直播| 中文字幕av网站| 蜜臀av一级做a爰片久久| 国产亚洲综合av| 国语对白中文字幕| 岳的好大精品一区二区三区| 国产一二三av| 在线观看视频一区二区| 日韩欧美国产综合在线| a v视频在线观看| 日韩三级视频| 99精品在线免费观看| 69欧美性猛交| 四虎精品一区二区三区| 欧美人妻精品一区二区免费看| 宅男噜噜噜66国产免费观看| 一区二区理论电影在线观看| 欧美s码亚洲码精品m码| 日韩丝袜美女视频| 国产精品99久久久久久久久| eeuss影院在线观看第一页| 精品日韩99亚洲| 国产精品第一国产精品| 夜夜躁狠狠躁日日躁2021日韩| 欧美91精品久久久久国产性生爱| 日韩欧美在线观看一区二区三区| 人善交vide欧美| 日韩欧美一区电影| 国产乱真实合集| 色综合一个色综合| 国产91精品一区二区绿帽| www.中文字幕.com| 欧美野外性xxxxfeexxxx| 99自拍视频在线观看| 日本国产精品视频| 亚洲第一狼人社区| 欧美午夜影院| 亚洲欧美视频在线观看视频| 精品国自产拍在线观看| 欧美日韩国产页| 亚洲成人av综合| 亚洲成人精品久久久| 免费观看在线色综合| 久久99国产综合精品免费| 国产精选一区二区三区| 久久青青草原一区二区| 国产黑丝在线视频| 天堂网中文在线观看| 久久密一区二区三区| 国产aaa精品| 亚洲av综合色区无码一区爱av| 性欧美大战久久久久久久久| 男女裸体影院高潮| 国产永久免费观看| 日本网站在线看| 蜜桃av在线免费观看| 国产另类ts人妖一区二区| 久久精品视频va| 少妇人妻在线视频| 欧美成人三级电影在线| 日本老太婆做爰视频| 蜜臀av国产精品久久久久| 黄色一级大片在线免费观看| 丝袜美腿高跟呻吟高潮一区| 国产精品三级在线| 亚洲视频免费播放| 国精品一区二区三区| 国产精品乱码久久久| 午夜在线视频观看| 99精品一区二区三区的区别| 日韩视频中文字幕在线观看| 亚洲黄色一区二区三区| 亚洲一区二区五区| 免费在线观看毛片网站| 51成人精品网站| 久久国产精品亚洲| 欧美人与牲动交xxxxbbbb| 欧亚av在线| 免费在线国产精品| 99热国内精品永久免费观看| 国产肥白大熟妇bbbb视频| 一个人看的免费网站www视频| 日韩欧美天堂| 男女啪啪免费观看| 黄色不卡一区| 日韩美女福利视频| 免播放器亚洲一区| proumb性欧美在线观看| 99久久久久久99| 久久av中文字幕片| 日本午夜精品一区二区三区电影| 国产suv精品一区二区69| 亚洲国产高清一区二区三区| 黄色在线免费网站| 精品视频第一区| 国产人成免费视频| 欧美91精品久久久久国产性生爱| 麻豆91精品| 奇米四色7777| 欧美 日韩 国产 一区二区三区| 91超碰国产在线| 91精品无人成人www| 黄色小说综合网站| 国产欧美激情视频| 天天在线免费视频| √天堂资源在线| 亚洲欧美视频在线播放| 97精品视频在线播放| 综合日韩在线| 欧美激情欧美激情在线五月| 麻豆av福利av久久av| 日韩福利片在线观看| 不卡的av网站| 国产性xxxx高清| 午夜免费在线| 97久久精品人人澡人人爽缅北| 在线色视频观看| 在线视频中文亚洲| 西西人体一区二区| 久久免费电影| 韩国自拍一区| 国产自产在线视频一区| zztt21.su黑料网站| av电影在线地址| 日本免费在线视频不卡一不卡二| 亚洲天堂第一页| 黄页免费在线观看视频| 久久国产精品1区2区3区网页| 亚洲天堂视频一区| 日韩欧美自拍| 久草.com| 日韩电影av| 成人免费视频视频在| 在线观看免费黄色| 亚洲精品自产拍在线观看app| 日韩成人伦理电影在线观看| 黄色小网站在线观看| 色窝窝无码一区二区三区| 久青草国产在线| 亚洲福利视频久久| 久久综合久久色| 欧美国产日本视频| 国产精彩精品视频| 怡红院av久久久久久久| 糖心vlog在线免费观看| 欧美日韩不卡| 福利视频导航一区| 亚洲尤物视频网| 亚洲国产精品一区在线观看不卡| 精品免费av一区二区三区| 99久久免费精品国产免费|