Home > Backend Development > PHP Tutorial > Should single-line comments be placed at the end of the line or above the code?

Should single-line comments be placed at the end of the line or above the code?

WBOY
Release: 2023-03-01 14:22:01
Original
1611 people have browsed it

If it is necessary to add a single-line comment, do developers generally put the single-line comment at the end of the code line, or should it be placed on its own line above the code? Or is it a specific situation and detailed analysis? Is it a personal habit or does it have your reasons. I hope everyone can discuss it so that I can learn more.

  • End of line

<code>var var1 = 5; // 声明并初始化变量,值为5</code>
Copy after login
  • Above

<code>// 声明并初始化变量,值为5
var var1 = 5; </code>
Copy after login
Related labels:
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