Home  >  Article  >  How to add code comments?

How to add code comments?

青灯夜游
青灯夜游Original
2019-04-19 11:04:5217687browse

You can pass in the code: //comment, /*comment*/, e05c4b47b13fdc91df7336c657836442, #comment, '''comment''', --comment, 'comment, %comment and so on to add comments. The following article will introduce you to the methods of code annotation by category. I hope it will be helpful to you.

How to add code comments?

Common code comment methods:

HTML comments

<!--这里是注释-->

CSS Comments

/*这里是注释*/

JavaScript Comments

Single Line Comments:

//这里是注释

Block (Multiple lines) Comments:

/*这里是注释*/

XML Comments

<!--这里是注释-->

C/C /C# Code Comments

Single-line comments:

//这里是注释

Block (multi-line) comments:

/*这里是注释*/

Java comments

Single-line comments:

//这里是注释

Block (multi-line) comments:

/*这里是注释*/

Python comments

Single-line comments:

#这里是注释

Block ( Multiple lines) Comment:

&#39;&#39;&#39;这里是注释&#39;&#39;&#39;

VB comment

&#39;这是一个单行注释

Note: It is a single quote followed by the comment

perl comments

Single line comments:

# 这是一个单行注释

Block (multiline) comments:

=pod 
这里是注释
=cut

Matlab comments

Single-line comments:

%这里是注释

Block (multi-line) comments:

%%这里是注释%%
%{这里是注释%}

R language comments

Single-line comments:

#这里是注释

Block (multi-line) comments:

if(false){这里是注释}

Why add comments?

Comments are "hints" or "explanations" of the code, not documents; comments are mainly used to explain code complexity; comments should be accurate and easy to understand (unambiguous) sex), concise; the amount of effective comments in the program must be more than 20%. It is definitely a good habit to add comments to the code. It is best to comment while writing the code

The purpose of comments: to facilitate the maintenance of the code, explain the functions and methods of the code, facilitate readers to read, and prevent unnecessary duplication of information .

Note: If the code is clear and self-explanatory, there is no need to add comments. Overly detailed comments can easily make people bored. Remember not to think that others cannot understand it without adding comments.

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of How to add code comments?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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