PHP coding specifications (23)

Source: Internet
Author: User
9.1 constants are numeric constants in the for loop that act as counter values. except for-and 1, they should not be directly written into code. 9.2 assign a value to a variable to avoid assigning the same value to multiple variables in a statement. It is hard to understand. For example: $ fooBar. fChar $ barFoo. lcharc; // do not assign a value to SyntaxHighlighter. al. 9.1 constants

The numeric constant located in the for loop as the counter value, except for-and 1, should not be directly written into the code.

9.2 variable assignment

Avoid assigning the same value to multiple variables in a statement. It is hard to understand. For example:
$ FooBar. fChar = $ barFoo. lchar = c; // error

Do not use the value assignment operator in areas that are easily confused with equality operators. For example:
If ($ c ++ = $ d ++) {// error
...
}

It should be written
If ($ c ++ = $ d ++ )! = 0 ){
...
}

Do not use the embedded (embedded) assignment operator to improve runtime efficiency, which is the work of the compiler. For example:
$ D = ($ a = $ B + $ c) + $ r; // error

It should be written
$ A = $ B + $ c;
$ D = $ a + $ r;


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.