详细讲解phpCB批量转换的代码示例
来源:互联网 发布:centos lamp 编辑:程序博客网 时间:2024/06/05 08:07
我们在使用PHP语言的时候会遇到转换图片文件的需求。如果实现批量转换的话,就能节约大量的时间。下面我们就为大家具体讲解有关phpCB批量转换的方法。
最近需要整理一个整站的php代码规范视图,前几天发现phpCB整理视图非常好,但有个缺点是不能批量处理,使用过程中发现phpCB是一个CMD程序,马上就想到php的system函数调用cmd,想到就做,下面是phpCB批量转换的php程序:
- < ?
- header("Content-type: text/html; charset=gb2312");
- define('ROOT_PATH', dirname(__FILE__));
- $topath="ww"; //要格式化视图的目录名,前后都不要“/”
- $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批量转换的使用方法:把phpCB.exe放在windows/system32/目录下,php执行程序和要转换的文件夹放同一级路径,先配置$topath,然后在浏览器里访问本程序,没有结果输出。
- 详细讲解phpCB批量转换的代码示例
- editplus+phpCB 简单的PHP代码格式化工具
- MySQL权限的详细讲解和示例
- phpCB 批量格式化php文件 经典方法
- ASP的类型转换函数(详细讲解)
- 一个简单的form示例(代码讲解)
- 详细讲解:蓝屏代码的解答
- Redux入门示例与数据流的详细讲解
- 基于Dubbo协议的项目示例及详细讲解(二)
- 代码编码批量转换
- 【Android LibGDX游戏引擎开发教程】第03期:示例代码详细讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- Android Jni代码示例讲解
- ubuntu 12.04 开启root
- MYLP标签打印程序
- OCS: OCS 2007上利用命令行发送广播消息
- DHCP协议
- Eclipse zest绘图
- 详细讲解phpCB批量转换的代码示例
- Python中的异常类型
- Web前端之struts2框架基于uploadify上传
- Android Handler
- OCS LYNC: Asterisk 1.6 with OCS 2007 OR LYNC 2010
- java面试小结
- Wax框架简明教程(1) 简介
- mysql语句实现php函数explode()的分割字符串功能
- 简单题练习——翻转单词顺序