PHP code comments are written in front
Annotations can be interpreted as explanations and descriptions in the code. The use of annotations not only improves the readability of the program, but also facilitates the later maintenance of the program. The comment content is not executed by the program.
Personal Project
Personal Website: LN movie network personal blog: L & N blog
PHP comments
PHP comments have 3 styles
1. C ++ style single line comment (//)
// This is a comment: print hello worldecho 'Hello World ';
2. C ++-style multi-line comments (/**/)
/* This is a multi-line comment echo 'hao'; echo 'this world'; */echo "hello this world ";
3. use Shell-style annotations (#)
Similar to a single-line comment, # The row is not executed
Echo 'hello this world'; # shell style comment, the content here will not be executed
Valid PHP comments
Program annotation is an important part of writing standard programs. Annotations are mainly used to explain and explain the code. they are used to explain the script usage, copyright description, version number, generation date, author, and content. Help to read and understand the program
Annotation principles
Language
- The annotation language must be accurate, easy to understand, and concise.
Note: incorrect comments are not helpful but harmful.
Annotations are ignored during code compilation and are not compiled into the final executable file by the compiler. Therefore, annotations do not increase the execution file size.
Annotations can be written anywhere in the code, but are generally written at the beginning or end of the code.
Note: Avoid inserting comments in a line of code or expression. Otherwise, comprehension deviations may occur.
When modifying the program code, you must modify the relevant comments at the same time to ensure that the code and comments are synchronized.
In actual code specifications, it is required that the proportion of comments to program code should be about 20%, that is, 20 comments to 100 lines of code
Note: avoid unnecessary comments
Add comments to the right of the end line of the block to indicate that a program is about to end.
Avoid using abbreviations in comments.
Comments are the same abbreviations as the descriptions, so that the program can be neatly formatted and easy to read and understand.
Summary
If we want to be a rigorous and attitude programmer, these seemingly insignificant principles actually represent a kind of responsible attitude towards the program we write.