Learning php annotations

The function of annotation is very powerful

The so-calledannotationcan be explained in Chinese as: annotation. More accurate.
Because the code is in English and the code is very long, people will forget it after a long time.
So we will addcomments.

Comments have many functions:

1. Mark the key points

2. It is easy to forget to recall quickly after a long time, making it easy to find

3. Let others understand quickly when they read it

4. You can also generate documents. After the code is written, the relevant documents are finished, improving work efficiency

5. Comments, blank lines, and carriage returns The subsequent code will look more beautiful

6. Comments can be used for troubleshooting. If you are not sure which part of the code is wrong, you can comment a large section to determine the error range

7. The computer will not execute the content in the middle of the comment

Let me give it to you first Take a look at the code that we think is beautiful, neat, standardized, clearly explained, and easy to understand at a glance. (No need to understand the meaning of the code):

2015-07-26_55b45e4f5550a.png

Let’s look at the code that we think is ugly, not to mention the alignment and ugliness, and there is no functional description (no need to understand the meaning of the code) ):

2015-07-26_55b45dfadd672.png

We have learned about the benefits of comments. Next, let’s talk about PHP comments. The comments are:

  • # #Single-line comment (comment only one line)

  • Multi-line comment (comment multiple lines)

  • Single-line comments

  • // 表示单行注释 # #号也表示单行注释,用的比较少
  • Multi-line comments

  • /* 多行注释 这里是注释区域代码 */

Single-line comment example:

Note: From the above example, we know that comments are usually written above the code.

Example of multi-line comments:

Note: Through the above example, we found that when we want to write a lot of comments, use multi-line comments.

Note: I will not explain how to generate comments through special tools for now

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!