时时商务社区

标题: 深入解析phpCB批量转换的代码示例 [打印本页]

作者: 新格网络    时间: 2018-2-14 08:16

            我们在使用PHP语言的时候会遇到转换图片文件的需求。如果实现批量转换的话,就能节约大量的时间。下面我们就为大家具体讲解有关phpCB批量转换的方法。
最近需要整理一个整站的php代码规范视图,前几天发现phpCB整理视图非常好,但有个缺点是不能批量处理,使用过程中发现phpCB是一个CMD程序,马上就想到php的system函数调用cmd,想到就做,下面是phpCB批量转换的php程序:
[U]复制代码[/U] 代码如下:
".$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,然后在浏览器里访问本程序,没有结果输出。
            
            
        




欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2