PHP代码加密 -- php_strip_whitespace函数,去掉源代码所有注释和空格并显示在一行
<?php
function stripCommentAndWhitespace($path = '')
{
if (empty($path)) {
echo '请指定要操作的文件路径';
return false;
} else {
$path = str_replace('\\', '/', $path);
}
if ( $handle = opendir ( $path )) {
while ( false !== ( $fileName = readdir ( $handle ))) {
if ( $fileName != "." && $fileName != ".." ) {
if (is_file($path . '/' . $fileName)) {
// 压缩.php后缀文件
$suffix = pathinfo($path . '/' . $fileName, PATHINFO_EXTENSION);
if ($suffix == 'php') {
$newFile = php_strip_whitespace($path . '/'. $fileName);
file_put_contents($path . '/'. $fileName, $newFile);
}
}
if (is_dir($path . '/' . $fileName)) {
stripCommentAndWhitespace($path . '/' . $fileName);
}
}
}
closedir ( $handle );
}
}
stripCommentAndWhitespace('YourProjectNamePath');
?>
最新文章
- [LeetCode] Palindrome Partitioning II 拆分回文串之二
- Web Essentials之Browser Link
- Android环境搭建和编写helloworld
- 浅谈JS中的继承
- getSelection、range 对象属性,方法理解,解释
- 探究JavaScript中的五种事件处理程序
- Arithmetic Progressions
- Java 多线程间的通讯
- vi使用入门指南
- C语言中的结构体和C++中的结构体以及C++中类的区别
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- DHot.exe 热点新闻
- hdu_5862_Counting Intersections(扫描线)
- C语言精神
- 11.4、Libgdx的音频之录制PCM音效
- MySQL(数据类型和完整约束)
- 微信小程序开发--路由切换,页面重定向
- Spring配置文件中的那些标签意味着什么(持续更新)
- VI常用命令及linux下软件
- Qt自定义控件大全(一)云台仪表盘控件
热门文章
- 《Java数据结构与算法》笔记-CH2有序数组
- Codeforces 377
- Unity中的单实例
- (转)UML常用图的几种关系的总结
- Java IO (4) - Writer
- HDU 1455 http://acm.hdu.edu.cn/showproblem.php?pid=1455
- codeforces 624A Save Luke(水题)
- git 入门学习笔记
- MySQL timestamp用法
- Unity3D之ScriptableObject学习笔记