PHP Code beautification Tool-phpcodebeautifier[integrated in editplus]_php tutorial

Source: Internet
Author: User
Tags coding standards pear
Use PHPCB to add a PHP code to EditPlus tool

PHP code formatting tools that can be integrated in editplus or other editors: Phpcodebeautifier, abbreviated PHPCB.
It can beautify the PHP code format, so that the format of the chaotic PHP code is very neat.


After installing the EDITPLUSR, in the menu bar, there are "tools (T)", "Configure User Tools" menu, opened, we click "User Tools", "Add Tools", "Application".
Menu text: PHP code beautification; command: Select the native save address for PHPCB.
Parameter write: $ (FilePath) or the following (command is one line), refer to Phpcodebeautifier User Manual for details.
--space-after-if--optimize-eol--space-after-switch--space-after-while--space-before-start-angle-bracket-- Space-after-end-angle-bracket--extra-padding-for-case-statement--glue-amperscore-- Change-shell-comment-to-double-slashes-comment--indent-with-tab--force-large-php-code-tag-- Force-true-false-null-contant-lowercase--comment-rendering-style PEAR--equal-align-position 50-- Padding-char-count 1 "$ (FilePath)"

Initial Catalog fill: $ (filedir)
Last Note select: "Run text filter", select "Replace" in the drop-down box,

In this way, our PHP code beautification tool has been added,
When you need to use it, just select the PHP Code tool in the menu bar,
Then the program will automatically organize our messy code, making our code more beautiful, easy to read and analyze.

http://www.waterproof.fr/products/phpCodeBeautifier/manual.php
Phpcodebeautifier User Manual
Options
--space-after-start-bracket:allow to insert a space after start bracket "(".

With--space-after-start-bracket without--space-after-start-bracket

if ($condition) {
}

?>

if ($condition) {
}

?>
--space-before-end-bracket:allow to insert a space before end bracket ")".

With--space-before-end-bracket without--space-before-end-bracket

if ($condition) {
}

?>

if ($condition) {
}

?>
--space-after-if:allow to insert a space after "if" keyword.

With--space-after-if without--space-after-if

if ($condition) {
}

?>

if ($condition) {
}

?>
--space-after-switch:allow to insert a space after "switch" keyword.

With--space-after-switch without--space-after-switch

Switch ($condition) {
}

?>

Switch ($condition) {
}

?>
--space-after-while:allow to inserts a space after the "while" keyword.

With--space-after-while without--space-after-while

while ($condition) {
}

?>

while ($condition) {
}

?>
--space-before-start-angle-bracket:allow to insert a space before starting angle bracket "{".

With--space-before-start-angle-bracket without--space-before-start-angle-bracket

while ($condition) {
}

?>

while ($condition) {
}

?>
--space-after-end-angle-bracket:allow to insert a space after starting angle bracket "}".

With--space-after-end-angle-bracket without--space-after-end-angle-bracket

while ($condition) {
}//End of while

?>

while ($condition) {
}//End of While

?>
--extra-padding-for-case-statement:increase padding before case statements.

With--extra-padding-for-case-statement without--extra-padding-for-case-statement

Switch ($condition) {
Case 1:
Action1 ();
Break
Case 2:
Action2 ();
Break
Default
DefaultAction ();
Break
}

?>

Switch ($condition) {
Case 1:
Action1 ();
Break
Case 2:
Action2 ();
Break
Default
DefaultAction ();
Break
}

?>
--one-true-brace-function-declaration:use "One true brace" formating for functions.

With--one-true-brace-function-declaration without--one-true-brace-function-declaration

function Afunction ($param)
{
function content
}

?>

function Afunction ($param) {
function content
}

?>

--glue-amperscore:glue "&" to following item.

With--glue-amperscore without--glue-amperscore

$value = & $objectInstance;

?>

$value = & $objectInstance;

?>
--change-shell-comment-to-double-slashes-comment:change "# ..." comment into "//..." comments.

Source with--change-shell-comment-to-double-slashes-comment without-- Change-shell-comment-to-double-slashes-comment

#comment Content
Another comment

?>

Comment Content
Another comment

?>

# comment Content
Another comment

?>
--indent-with-tab:if selected, tabulation (ASCII #9) character is used to indent text, elsewhere space (ASCII #32) Charac TER is used.

--force-large-php-code-tag:change "Into "?> ".

Source with--force-large-php-code-tag without--force-large-php-code-tag

?>

<%

%>

?>

?>

?>

<%

%>
--force-true-false-null-contant-lowercase:lowercase for NULL, true and false constants as encouraged in PEAR coding stand Ards.

Source with--force-true-false-null-contant-lowercase without--force-true-false-null-contant-lowercase

if (TRUE) {
if (FALSE) {
$value = NULL;
}
}

?>

if (true) {
if (false) {
$value = null;
}
}

?>

if (TRUE) {
if (FALSE) {
$value = NULL;
}
}

?>
--align-equal-statements:align all assignement statements.

Source with--align-equal-statements

$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;

$anotherVariable [0123] = \ ' bla bla bla\ ';

$showBlaBlaBlaMessage = false;

?>
$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;
$anotherVariable [0123] = \ ' bla bla bla\ ';
$showBlaBlaBlaMessage = false;

?>

--align-equal-statements-to-fixed-pos:align all assignement statements to a fixed position.

Source with--align-equal-statements-to-fixed-pos 30

$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;

$anotherVariable [0123] = \ ' bla bla bla\ ';

$showBlaBlaBlaMessage = false;

?>
$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;
$anotherVariable [0123] = \ ' bla bla bla\ ';
$showBlaBlaBlaMessage = false;

?>

Comment Rendering Style
The following style of comment formating is available:

--comment-rendering-style PEAR--comment-rendering-style PHPDoc

/**
* Bla bla bla
*
* @access Public
*/

?>

/**
* Bla bla bla
*
* @access Public
*/

?>
PEAR Coding Standards Tips
To follow PEAR coding standards, I-recommend you-use the following configuration:

Option State
--space-after-start-bracket-
--space-before-end-bracket-
--space-after-if X
--space-after-switch X
--space-after-while X
--space-before-start-angle-bracket X
--space-after-end-angle-bracket X
--extra-padding-for-case-statement-
--one-true-brace-function-declaration X
--glue-amperscore X
--change-shell-comment-to-double-slashes-comment X
--indent-with-tab-
--force-large-php-code-tag X
--force-true-false-null-contant-lowercase X
--align-equal-statements X
--align-equal-statements-to-fixed-pos-
Use 4 for the padding character count to use.

Command Line
Command Line syntax is the following:

PhpCB.exe [Options] [Srcfile]
The Where options are from the previous topic list and srcfile are the file to beautify. If no srcfile is given, the standard input would be used. The transformed text'll is outputted to standard output and you can redirect it to a file using the > symbol.
Example
This was a sample call of the command line version:

# PHPCB--space-after-if \
--space-after-switch \
--space-after-while \
--space-before-start-angle-bracket \
--space-after-end-angle-bracket \
--one-true-brace-function-declaration \
--glue-amperscore \
--change-shell-comment-to-double-slashes-comment \
--force-large-php-code-tag \
--force-true-false-null-contant-lowercase \
--align-equal-statements \
--comment-rendering-style PEAR \
--equal-align-position 50 \
--padding-char-count 4 \
c:\some\path\to\file.php

http://www.bkjia.com/PHPjc/477960.html www.bkjia.com true http://www.bkjia.com/PHPjc/477960.html techarticle use PHPCB to add PHP code formatting tools for EditPlus that can be integrated in editplus or other editors: Phpcodebeautifier, abbreviated as PHPCB. It can beautify the PHP code ...

  • 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.