Annotation symbols and formats I think many php referers will only be simple or, next, I will introduce to you in detail the annotation symbols and formats in php. For more information, see PHP.
Annotation symbols and formats I think many php referers only use simple // or, next I will give you a detailed introduction to the annotation symbols and formats in php. For more information, see.
PHP Annotator
■ C ++ style: // This is a C + style comment
■ C style:/* This is a C style comment */
■ Unix Shell style: # This is a Unix Shell style comment
Generally, '//' and '/* comment content */' are used. In addition, some system configuration documents, such as php, are used to build the php environment. the annotation symbol in ini is.
PHP comment format
The PHP comment format is divided into single-line comment and multi-line comment.
PHP single line comment
The above three symbols can be used for single-line comments. only when the // or # Annotator is used, the text (within the same line) after the Annotator is considered as the comments, the/**/style annotator must end.
The instance code is as follows:
-
- // This is a single line comment
- Echo 'Hi! '; // This is a single line comment
- /* Comment */
- ?>
The comment at the end of the line above usually only comments the content before the line. the comment for a single line may be comments for the following line or multiple lines of code, it may also be for the overall appearance of the program.
PHP multi-line comment
Multi-line comments generally use a C-style annotator, which starts with/* and ends with */to contain multi-line comments:
The instance code is as follows:
-
- Echo "Hello! ";
- /* Multi-line comment content */
- ?>
Note:
Do not use the C-style annotator nested, because when the first */is reached, the system considers that the annotation of this paragraph to end. this error is very likely to occur when a large piece of code is commented out. PHP syntax errors may occur if the following statements are used:
The instance code is as follows:
-
- Echo 'Hi! ';
- /*
- This is a multiline comment
- Echo 'output other content';/* added comments of the row */
- */
- ?>
You can also use the // symbol multiple times to annotate multiple lines of code:
The instance code is as follows:
-
- // Annotation
- // Description 1
- // Description 2
- Echo 'annotation example ';
- }
- ?>
PHP comments cannot contain the PHP code Terminator:?>, This is because PHP detects the Terminator, that is, it considers that the execution of the PHP code in this section will lead to program errors. another point is that a good php editor can save us a lot of trouble. for example, phpdesigner and zend.