PHP coding specification comments and file structure descriptions

Source: Internet
Author: User
Understand the annotation and file structure of PHP coding specifications, and write the code and directory structure of rules so that everyone can quickly get familiar with them. Improve collaboration efficiency.

Understand the annotation and file structure of PHP coding specifications, and write the code and directory structure of rules so that everyone can quickly get familiar with them. Improve collaboration efficiency.

File structure

|-Images
|-Include
|-Parameter
|-Config
| -- Function
| -- Index
Images Stores image files. include is a file to be referenced by the system. It generally stores parameter files in parameter, config stores configuration files, and function stores method files, for example, javascript methods, and the classes of each function are also classified by functional modules.
File Name
Folder names are generally in English and generally contain no more than 20 characters. Chinese Pinyin is used only in special cases. Some common folder names include: images (storing graphic files), flash (storing Flash files), and style (storing CSS files ), scripts (storing Javascript scripts), inc (storing include files), link (storing links), and media (storing multimedia files. The file name must contain lowercase letters, numbers, and underscores.
Block comment
Block annotations are usually used to provide descriptions of files, methods, data structures, and algorithms. Block annotations are placed at the beginning of each file and before each method. They can also be used in other places, such as internal methods. Block comments inside functions and methods should have the same indent format as the code they describe.
There should be a blank line at the beginning of the block comment to separate the block comment from the code, for example:
/*
* Here is the block comment.
*/
The block annotation can start with/*-, so that indent (1) can recognize it as the beginning of a code block without shuffling it.
/*-
* If you want to be ignored, block annotations in special format are used.
*
* One
* Two
* Three
*/
Note: if you do not use indent (1), you do not need to use/*-in the Code, or make concessions for others to run indent (1) on your code.
Single line comment
A short comment can be displayed in a row and has the same indentation level as the subsequent code. If a comment cannot be written in a row, block comment should be used. There should be a blank line before a single line comment. The following is an example of a single line comment in the Code:
If (condition ){
/* Conditions for running the following code */
...
}
End comment
Very short comments can be in the same line as the code they want to describe, but there should be enough white space to separate the code and comments. If multiple short comments appear in a large code segment, they should have the same indentation.
The following is an example of the end comment in the Code:
The Code is as follows:
If ($ a = 2 ){
Return TRUE;/* description of a single condition */
} Else {
Return isPrime ($ a);/* Other conditions */
}

End comment
The annotator "//". You can comment out a part of the entire line or a row. It is generally not used for comments of multiple consecutive rows; however, it can be used to comment out code segments of multiple consecutive rows. The following are examples of all three styles:
The Code is as follows:
If ($ foo> 1 ){
// Second usage.
...
}
Else {
Return false; // The reason for the returned value
}
// If ($ bar> 1 ){
//
/// Method 3
//...
/

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.