Detailed code examples for PHPCB batch Conversion _php Tutorial

Source: Internet
Author: User
Tags tidy
We are using

Recently need to tidy up a whole station PHP code specification view, the previous days found PHPCB tidy view is very good, but there is a drawback is not batch processing, using the process found PHPCB is a CMD program, immediately think of PHP system function call cmd, think about doing, The following is a PHPCB batch conversion PHP Program:

  1. < ?
  2. header ("content-type:text/html; CharSet = gb2312 ");
  3. Define (' Root_path ', DirName (__file__));
  4. $ Topath = "WW" / //To format the view directory name, do not front and back "/"
  5. $ Path = Root_path ." /". $topath;
  6. $ arr = Get_all_files ($path);
  7. For ($i=0; $i<count($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. ?>

PHPCB the use of batch conversion: Put PhpCB.exe in the windows/system32/Directory, PHP execution program and the folder to be converted to the same level of path, first configure the $topath, and then access the program in the browser, no results output.


http://www.bkjia.com/PHPjc/446130.html www.bkjia.com true http://www.bkjia.com/PHPjc/446130.html techarticle we are using the recent need to tidy up a full site of the PHP Code specification view, a few days ago found PHPCB tidy view is very good, but there is a drawback is not batch processing, using the process found PHP ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.