爱程序网

PHP代码加密 -

来源: 阅读:

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

?>

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助