Home  >  Article  >  php教程  >  Thinkphp HTML输出压缩类 Minify

Thinkphp HTML输出压缩类 Minify

WBOY
WBOYOriginal
2016-06-07 11:43:451969browse

CI3.0自带了Minify页面压缩功能,也就是将页面中的空格之类的全部去掉,这样就能省下不少的空间。
当然,TP也自带的OUTPUT_ENCODE页面压缩功能,可是当我配置OUTPUT_ENCODE=TRUE时,老是提示"无法显示此网页"错误..所以,没办法,将CI的Minify功能移过来
1、将Minify.class.php放到AUTO自动加载目录下
2、在配置文件中设置: 'MINIFY' => true,
3、在View.class.php中的render的方法增加:
private function render($content,$charset='',$contentType=''){

//2013-10-3 增加milify
if(C('MINIFY')){
echo Minify::compress($content);
}else{
// 输出模板文件
echo $content;
}
}

附件 Minify.class.rar ( 2.41 KB 下载:142 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn