<?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');

?>

最新文章

  1. [LeetCode] Palindrome Partitioning II 拆分回文串之二
  2. Web Essentials之Browser Link
  3. Android环境搭建和编写helloworld
  4. 浅谈JS中的继承
  5. getSelection、range 对象属性,方法理解,解释
  6. 探究JavaScript中的五种事件处理程序
  7. Arithmetic Progressions
  8. Java 多线程间的通讯
  9. vi使用入门指南
  10. C语言中的结构体和C++中的结构体以及C++中类的区别
  11. android中通过自定义xml实现你需要的shape效果 xml属性配置
  12. DHot.exe 热点新闻
  13. hdu_5862_Counting Intersections(扫描线)
  14. C语言精神
  15. 11.4、Libgdx的音频之录制PCM音效
  16. MySQL(数据类型和完整约束)
  17. 微信小程序开发--路由切换,页面重定向
  18. Spring配置文件中的那些标签意味着什么(持续更新)
  19. VI常用命令及linux下软件
  20. Qt自定义控件大全(一)云台仪表盘控件

热门文章

  1. 《Java数据结构与算法》笔记-CH2有序数组
  2. Codeforces 377
  3. Unity中的单实例
  4. (转)UML常用图的几种关系的总结
  5. Java IO (4) - Writer
  6. HDU 1455 http://acm.hdu.edu.cn/showproblem.php?pid=1455
  7. codeforces 624A Save Luke(水题)
  8. git 入门学习笔记
  9. MySQL timestamp用法
  10. Unity3D之ScriptableObject学习笔记