The function of annotation is very powerful
The so-called annotation can 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 add comments.
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):
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) ):
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:
<?php //声明一部iphone6手机的价格变量 $iphone6_price = 6088; //显示输出手机价格 echo $iphone6_price; ?>Note: From the above example, we know that comments are usually written above the code. Example of multi-line comments:
<?php /* 作者:PHP中文网 时间:2048.12.23 功能:这是一个假的多行注释的例子 */ /* 声明一个爱情变量 $love 是指爱情 爱情是一个变量,因为人的爱总是在发生变化 所以,爱情变量的值为250 */ $love = 250; ?>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