An in depth code example to parse the phpCB batch conversion

  • 2020-06-22 23:57:56
  • OfStack

We encountered the need to convert image files when using the PHP language. If you implement batch conversion, you can save a lot of time. Below we will explain the phpCB batch conversion method in detail.

Recently, I need to sort out the php code specification view of a whole site. A few days ago, I found that phpCB tidy view is very good, but there is a disadvantage is that it cannot be processed in batches. During the use, I found that phpCB is an CMD program.

< ?  
header("Content-type: text/html; charset=gb2312");  
define('ROOT_PATH', dirname(__FILE__));  
$topath="ww"; // To format the directory name of the view, do not "before" or "after" / "   
$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 batch conversion method: put ES17en. exe in windows/system32/ directory, php execution program and the folder to be converted into the same level path, first configure $topath, and then access the program in the browser, no result output.

Related articles: