PHP Coding Specification (_php) tutorial

Source: Internet
Author: User
9.3 Curly Braces

Of the three main braces placement rules, two are acceptable, as the first of these is the best:
Place curly braces at the same column below the keyword:
if (condition)
{
...

while (condition)
{
...
}
}
The traditional Unix parentheses rule is that the first brackets are the same as the keywords, and the end brackets are the same as the keywords:
if (condition) {

...

while (condition) {

...

}
}
The non-principled problems that cause the violent controversy can be solved by means of compromise, either of which is acceptable, but for most people the first one is preferred. The reason is that psychology studies the category of learning things.
There are more reasons for liking the first. If you use a character editor that supports brace matching (for example, VI), the most important thing is to have a good style. Why? We say when you have a big program and want to know where this big program ends. You first move to the opening parenthesis, and you press the button editor to find the closing parenthesis that corresponds to it, for example:

if (verylongcondition && secondverylongcondition)
{
...
}
else if (...)
{
...
}
Moving from one program block to another requires you to match the key with the cursor and your parentheses, without looking for matching parentheses.


http://www.bkjia.com/PHPjc/532579.html www.bkjia.com true http://www.bkjia.com/PHPjc/532579.html techarticle 9.3 Braces in the three main braces placement rules, two are acceptable, as the first of the following is best: Place curly braces at the same column below the keyword: if (c ...

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