Use phpED as the development tool. When the compressed PHP file is large, it is a pain to open it. PhpED strikes are often caused. The formatted PHP file is no problem when it is opened. In desperation, I wrote a PHP code batch formatting tool. Right-click the folder to format PHP code in batches. The Code is as follows:
1. Create a file named FormatPHP. bat. The content is as follows:
View Code
@ TITLE format PHP code path: % 1
@ Echo ************************************** ***************************
@ Echo *
@ Echo * PHP code file path: % 1
@ Echo * All. PHP and. php files under the path will be formatted.
@ Echo *
@ Echo * prompt: formatting takes some time! If you want to cancel the operation, close this window.
@ Echo *
@ Echo * ---- Create By rumen buyi
@ Echo *
@ Echo ************************************** ***************************
@ Pause
@ Echo *
@ Echo * Start formatting...
@ Echo *
@ Cd/D % 1
@ Set BackupPath = % 2
@ If "% BackupPath %" = "" @ set BackupPath = D: \ MyFile \ UltraEdit \ backup \ Date
@ Set phpCB = % 3
@ If "% phpCB %" = "" @ set phpCB = D: \ soft \ phpCB.exe
@ Set a = % cd % t
@ Set des = % BackupPath % \ % date :~ 0, 4% \ % date :~ 5, 2% \ % date :~ 8, 2% \ % time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2% \ % :~ 0, 1% \
@ FOR/r % 1% % f IN (*) DO @ call: FormatPHP1 % f % des % phpCB %
@ Echo ************************************** ***************************
@ Echo *
@ Echo * PHP formatting ends
@ Echo *
@ Echo ************************************** ***************************
Pause
@ Goto: eof
: FormatPHP1
@ Set FileName = % 1
@ Set des = % 2
@ Set phpCB = % 3
@ If "% FileName :~ -4,4% "=". php "@ call: FormatPHP2 % FileName % des % phpCB %
@ If "% FileName :~ -4,4% "=". PHP "@ call: FormatPHP2 % FileName % des % phpCB %
@ Goto: eof
: FormatPHP2
@ Set FileName = % 1
@ Set FilePath = % 2
@ Set phpCB = % 3
@ Set FileName2 = % FileName % t
@ Set FileBakup = % FilePath % FileName2 :~ 3,-1%
@ Echo F | xcopy "% FileName %" "% FileBakup %"/S/Y | echo off
@ Echo * current file: % FileName %
@ Echo * the backup is successful.
@ Echo * formatting...
@ "% Phpcb %" -- equal-align-position 50 -- padding-Char-count 4 -- space-after-If -- space-after-switch -- space-after-while -- glue -amperscore -- force-large-PHP-code-tag -- align-Equal-statements -- Comment-rendering-style pear -- extra-padding-for-case-statement -- glue-arrow -- optimize-EOL -- one-True-brace-function-Declaration "% filename %"> "% filename %. phpformatbak"
@ Move/y "% filename %. phpformatbak" "% filename %" | echo off
@ Echo * Format successful
@ Echo *
@ Goto: EOF
2. Create a reg-type file with the following content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE \ SOFTWARE \ Classes \ Folder \ shell \ formatphp]
@ = "Format PHP code"
[HKEY_LOCAL_MACHINE \ SOFTWARE \ Classes \ Folder \ shell \ formatphp \ command]
@ = "D :\\ MyFile \ UltraEdit \ save \ FormatPHP. bat % 1 D :\\ MyFile \ UltraEdit \ backup \ Date D :\\ soft \ phpCB.exe"
Where,
D: \ MyFile \ UltraEdit \ save \ FormatPHP. bat is the complete path of the bat file created in step 1;
D: \ MyFile \ UltraEdit \ backup \ Date is the folder used for backup code;
D: \ soft \ phpCB.exe is the complete path of phpCB.
The above three parameters should be modified according to the actual situation.
After executing the reg file, right-click the folder and a menu item named "format PHP code" appears.
Success!