Home > Backend Development > PHP Problem > What are the types of PHP comments?

What are the types of PHP comments?

(*-*)浩
Release: 2023-02-23 22:18:02
Original
8060 people have browsed it

PHP comments (Comments) have two types:

What are the types of PHP comments?

One is a single-line comment, the other The first is a multi-line comment.

PHP single-line comment syntax (Recommended learning: PHP programming from entry to proficiency)

All "//" symbols on the right side of a line The text is treated as a comment because the PHP parser ignores everything to the right of the line "//". An example is as follows: You can also write only comments in one line without writing code, as follows:

PHP multi-line comment syntax

PHP multi-line comments start with "/*", End with "*/". Between "/*" and "*/", you can write multiple lines of comments. The example is as follows, the red part is the content of multi-line comments.

Block comments

Block comments are typically used to provide descriptions of files, methods, data structures, and algorithms.

Block comments are placed at the beginning of every file and before every method; they can also be used elsewhere, such as inside methods.

Block comments inside functions and methods should have the same indentation 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 comment can start with /*-, so indent (C language formatting code) can recognize it as the beginning of a code block without rearranging it.

 /*- * 如果想被忽略,可是使用特别格式的块注释 *
 * one *   
  * two *
 *three */
Copy after login

Note: If you do not use indent (C language formatting code), you do not have to use /*- in your code, or other people may run indent (C language formatting code).

The above is the detailed content of What are the types of PHP comments?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template