深入解析phpCB批量转换的代码示例
2013-06-27 00:00
453 查看
我们在使用PHP语言的时候会遇到转换图片文件的需求。如果实现批量转换的话,就能节约大量的时间。下面我们就为大家具体讲解有关phpCB批量转换的方法。
最近需要整理一个整站的php代码规范视图,前几天发现phpCB整理视图非常好,但有个缺点是不能批量处理,使用过程中发现phpCB是一个CMD程序,马上就想到php的system函数调用cmd,想到就做,下面是phpCB批量转换的php程序:
phpCB批量转换的使用方法:把phpCB.exe放在windows/system32/目录下,php执行程序和要转换的文件夹放同一级路径,先配置$topath,然后在浏览器里访问本程序,没有结果输出。
最近需要整理一个整站的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,然后在浏览器里访问本程序,没有结果输出。
相关文章推荐
- java 二维码的生成与解析示例代码
- JavaScript解析URL参数示例代码
- 深入了解ibatis源码----简单ibatis示例代码
- J2ME KXML 解析中文xml代码示例
- 【OpenCV 学习】自带示例:随机数发生器&绘制文字 代码注释解析
- dom4j,读,写,解析,xml文件 示例代码
- 在java中使用dom4j解析xml(示例代码)
- js正则解析URL参数示例代码
- JSON数据解析代码示例
- 在JS中解析HTML字符串示例代码
- Spring实例化bean过程解析及完整代码示例
- 简单XML配置与解析(代码示例)
- 在java中使用dom4j解析xml(示例代码)
- 【深入实践ucos-ii】第一个示例程序代码
- java数据结构之树基本概念解析及代码示例
- jquery解析JSON数据示例代码
- 使用dom4j解析xml(示例代码)
- Java语言字典序排序算法解析及代码示例
- iPhone SDK 解析 xml的官方示例代码