国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

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

php實(shí)現(xiàn)的CSS更新類實(shí)例

2020-03-22 17:23:11
字體:
供稿:網(wǎng)友
本文實(shí)例講述了php實(shí)現(xiàn)的CSS更新類及其用法,非常實(shí)用。分享給大家供大家參考。具體如下:CSSUpdate.html' target='_blank'>class.php類文件如下: php /** css 更新類,更新css文件內(nèi)圖片的版本 * Date: 2013-02-05 * Author: fdipzone * Ver: 1.1 * Func: * update(); * Ver: 1.1 增加search_child參數(shù),可遍歷子文件夾 class CSSUpdate{ private $csstmpl_path = null; private $css_path = null; private $replacetags = array(); private $search_child = false; private $convert_num = 0; private $is_ready = 0; /** 初始化 * @param String $csstmpl_path css模版路徑 * @param String $css_path css目標(biāo)路徑 * @param Array $replacetags 需要替換的圖片類型 * @param boolean $search_child 是否遍歷子文件夾,默認(rèn)false public function __construct($csstmpl_path, $css_path, $replacetags=array(), $search_child=false){ if(!is_dir($csstmpl_path) || !is_dir($css_path) || !$replacetags){ $this- is_ready = 0; }else{ $this- csstmpl_path = $csstmpl_path; $this- css_path = $css_path; $this- replacetags = $replacetags; $this- search_child = $search_child; $this- is_ready = 1; /** 更新css文件 */ public function update(){ if($this- is_ready==0){ $this- response('csstmpl or csspath or replacetags error'); return ''; $this- traversing($this- csstmpl_path); $this- response('covert num:'.$this- convert_num); /** 遍歷文件夾 * @param String $path 文件路徑 private function traversing($path){ $handle = opendir($path); while(($file=readdir($handle))!==false){ if($file!='..' && $file!='.'){ $curfile = $path.'/'.$file; if(is_dir($curfile)){ // folder if($this- search_child){ // 需要遍歷子文件夾 $this- traversing($curfile); }elseif($this- checkExt($curfile)){ // css file $dfile = str_replace($this- csstmpl_path, $this- css_path, $curfile); $this- create($curfile, $dfile); $this- response($curfile.' convert to '.$dfile.' success'); $this- convert_num ++; closedir($handle); /** 檢查文件后綴 */ private function checkExt($file){ $name = basename($file); $namefrag = explode('.', $name); if(count($namefrag) =2){ if(strtolower($namefrag[count($namefrag)-1])=='css'){ // css文件 return true; return false; /** 替換模版內(nèi)容,寫入csspath * @param String $tmplfile 模版文件 * @param String $dfile 目標(biāo)文件 private function create($tmplfile, $dfile){ $css_content = file_get_contents($tmplfile); foreach($this- replacetags as $tag){ $css_content = str_replace($tag, $tag." ".date('YmdHis'), $css_content); if(!is_dir(dirname($dfile))){ // 生成目標(biāo)路徑 mkdir(dirname($dfile), 0755, true); file_put_contents($dfile, $css_content, true); /** 輸出 */ private function response($content){ echo $content." brPHP教程

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 萨迦县| 高平市| 柳州市| 贡嘎县| 开原市| 隆安县| 大城县| 弥渡县| 崇义县| 河西区| 聂拉木县| 长寿区| 北宁市| 治县。| 年辖:市辖区| 望谟县| 清涧县| 夹江县| 蒲城县| 利津县| 巢湖市| 宁安市| 富川| 扶风县| 苏尼特左旗| 乐都县| 上虞市| 斗六市| 和平县| 延边| 南郑县| 华亭县| 新余市| 卢氏县| 金川县| 雷山县| 深水埗区| 韩城市| 江城| 磐安县| 德州市|