Detailed explanation of code examples for phpCB batch conversion_PHP Tutorial

WBOY
Release: 2016-07-15 13:32:35
Original
939 people have browsed it

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:

  1. ?
  2. header("Content-type: text/html; charset=gb2312");
  3. define ('ROOT_PATH', dirname(__FILE__));
  4. $topath= "ww"; //To format the directory name of the view, do not use "/" before or after it
  5. $path=ROOT_PATH."/".$topath;
  6. $arr=get_all_files($path);
  7. for($i=0 ;$icount($arr);$i++)
  8. {
  9. $phpext=fileext($arr[$i]);
  10. if($phpext=="php")
  11. {
  12. $cmd="phpCB.exe ".$arr[$i]." > ".$arr[$i].".phpCB";
  13. system($cmd);
  14. unlink($arr[$i]);
  15. @rename($arr[$i].".phpCB",$arr[$i] );
  16. }
  17. }
  18. function get_all_files($path){
  19. $list = array( );
  20. foreach(glob($path . '/*') as $item){
  21. if(is_dir($item) ){
  22. $list = array_merge($list , get_all_files( $item ));
  23. } else {
  24. $list[] = $item;
  25. }
  26. }
  27. return $list;
  28. }
  29. function fileext($filename) {
  30. return trim(substr(strrchr($filename, '.') , 1, 10));
  31. }
  32. ?>

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.


www.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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!