php实现压缩合并js的方法【附demo源码下载】
2018-09-07 22:11
本文实例讲述了php实现压缩合并js的方法。分享给大家供大家参考,具体如下:
test.php文件如下:
require_once(jsmin.php); $files = glob(js/*.js); $js = ; foreach($files as $file) { $js .= JSMin::minify(file_get_contents($file)); } file_put_contents(combined.js, $js); echo success;
jsmin.php文件如下:
<?php /** * jsmin.php - PHP implementation of Douglas Crockfords 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 (
完整实例代码点击此处本站下载。
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php文件操作总结》、《PHP目录操作技巧汇总》、《PHP基本语法入门教程》、《PHP运算与运算符用法总结》、《php面向对象程序设计入门教程》、《PHP网络编程技巧总结》、《php字符串(string)用法总结》、《PHP数组(Array)操作技巧大全》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。