PHP coding specification (25)

Source: Internet
Author: User
9.3 braces are acceptable in two of the three main braces placement rules. The first is the best: place braces in the same column below the keyword: if (condition ){... while (condition ){...}} the traditional UNIX bracket rule is: SyntaxHighli 9.3 braces

Two of the three main braces are acceptable, and the first is the best:
Place braces in the same column below the keywords:
If (condition)
{
...

While (condition)
{
...
}
}
The traditional brackets of UNIX are the same as the keywords, and the ending brackets are the same as the keywords:
If (condition ){

...

While (condition ){

...

}
}
Non-principled issues that have aroused heated debate can be solved through a compromise. either of the two methods is acceptable, but most people prefer the first one. The reason is the scope of psychological research.
There are more reasons to prefer the first one. If the character editor you are using supports the bracket matching function (for example, vi), the most important thing is to have a good style. Why? We say that when you have a large program and want to know where it ends. Move the brackets to the beginning, and press the button editor to find the ending brackets. for example:

If (veryLongCondition & secondVeryLongCondition)
{
...
}
Else if (...)
{
...
}
To move from one block to another, you only need to use the cursor to match your brackets. no matching brackets are needed.


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.