phpCB 批量格式化php文件 经典方法
2010-07-02 17:13
501 查看
发现phpCB整理php文档非常好,但有个缺点是不能批量处理,使用过程中发现phpCB是一个CMD程
序。于是想到php的system函数调用cmd。将phpCB放到 系统文件夹 system下。
下面是phpCB批量转换的php程序:
序。于是想到php的system函数调用cmd。将phpCB放到 系统文件夹 system下。
下面是phpCB批量转换的php程序:
<? header ( "Content-type: text/html; charset=gb2312" ) ; define ( 'ROOT_PATH' , dirname ( __FILE__ ) ) ; $topath = "www" ; //要格式化视图的目录名,前后都不要“/” $path = ROOT_PATH. "/" . $topath ; $arr = get_all_files( $path ) ; for ( $i = 0 ; $i < count( $arr ) ; $i ++ ) { $phpext = fileext( $arr [ $i ] ) ; if ( $phpext == "php" ) { $cmd = "phpCB.exe " . $arr [ $i ] . " > " . $arr [ $i ] . ".phpCB" ; system ( $cmd ) ; unlink ( $arr [ $i ] ) ; @ rename ( $arr [ $i ] . ".phpCB" , $arr [ $i ] ) ; } } function get_all_files( $path ) { $list = array ( ) ; foreach ( glob ( $path . '/*' ) as $item ) { if ( is_dir ( $item ) ) { $list = array_merge ( $list , get_all_files( $item ) ) ; } else { $list [ ] = $item ; } } return $list ; } function fileext( $filename ) { return trim ( substr ( strrchr ( $filename , '.' ) , 1 , 10 ) ) ; } ?>
相关文章推荐
- phpCB 批量格式化php文件 经典方法
- php 批量生成html,txt文件的方法(实例代码)
- PHP实现格式化文件数据大小显示的方法
- PHP/ThinkPHP实现批量打包下载文件的方法示例
- PHP实现格式化文件数据大小显示的方法
- PHP批量修改文件名称的方法分析
- PHP实现批量重命名某个文件夹下所有文件的方法
- PHP实现格式化文件数据大小显示的方法
- PHP做下载文件的方法
- php实现SAE上使用storage上传与下载文件的方法
- PHP中获取文件扩展名的N种方法
- C#利用定时任务插件实现在后台线程中批量把动态文件生成静态文件方法
- 修改PHP上传文件大小限制的方法
- php读取文件的几种方法
- php 使用file_get_contents读取大文件的方法
- PHP同时上传“多个”文件示例,并格式化$_FILES数组信息
- PHP获取文件扩展名的方法
- php 解压rar文件及zip文件的方法
- PHP下载远程文件到本地存储的方法
- PHP递归遍历指定目录的文件并统计文件数量的方法