We are using
Recently we need to organize a PHP code specification view for the entire site. A few days ago I found that phpCB organizes the view very well, but one disadvantage is that it cannot be batched During the process, I found that phpCB is a CMD program. I immediately thought of the system function of php to call cmd. I did it as soon as I thought of it. The following is the php program for batch conversion of phpCB:
- ?
-
header("Content-type: text/html; charset=gb2312");
- define ('ROOT_PATH', dirname(__FILE__));
-
$topath= "ww"; //To format the directory name of the view, do not use "/" before or after it
-
$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));
- }
-
?>
How to use phpCB batch conversion: Place phpCB.exe in the windows/system32/ directory, the php executable program and the folder to be converted. For the same level path, first configure $topath, and then access this program in the browser, but no result will be output.
http://www.bkjia.com/PHPjc/446130.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446130.htmlTechArticleWe recently needed to organize a PHP code specification view for the entire site. A few days ago, we found that phpCB organized the view very well. , but one disadvantage is that it cannot be processed in batches. During use, I found that php...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn