您好,欢迎访问一九零五行业门户网

详细讲解phpCB批量转换的代码示例_PHP教程

我们在使用
最近需要整理一个整站的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;$icount($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,然后在浏览器里访问本程序,没有结果输出。
http://www.bkjia.com/phpjc/446130.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/446130.htmltecharticle我们在使用 最近需要整理一个整站的php代码规范视图,前几天发现phpcb整理视图非常好,但有个缺点是不能批量处理,使用过程中发现php...
其它类似信息

推荐信息