PHP coding specifications (22)

Source: Internet
Author: User
8.4 except for the variable name, all instances, including classes and class constants, use case-insensitive mixing. The first letter of the first word is lowercase, and the last word is capitalized. Variable names should not start with an underscore or dollar sign, although this is syntactically allowed. Variable names should be brief and descriptive. The variable name should be SyntaxHighlighter. all (); 8.4 variables

Except for the variable name, all instances, including class and class constants, are case-insensitive. The first letter of the first word is lowercase, and the first letter of the subsequent word is capitalized. Variable names should not start with an underscore or dollar sign, although this is syntactically allowed.
Variable names should be brief and descriptive. The selection of variable names should be easy to remember, that is, they can point out their purposes. Avoid the variable name of a single character unless it is a one-time temporary variable. Temporary variables are usually named I, j, k, m, and n. They are generally used for integer type; c, d, e, they are generally used for struct type.

Char $ c;
Int $ I;
Float $ myWidth;
8. instance variables

The case-sensitive rule is similar to the variable name, except for the preceding underline.

Int $ _ employeeId;
String $ _ name;
Customer $ _ customer;
8.6 constants

The declaration of class constants and ANSI constants should be in uppercase and words should be separated by underscores. (Avoid ANSI constants whenever possible, which may cause errors)

Static final int $ MIN_WIDTH = 4;
Static final int $ MAX_WIDTH = 999;
Static final int $ GET_THE_CPU = 1;


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.