Multiline comments vs. Singleline comments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Multiline comments vs. Singleline comments

Hey every, I apologize if this has already been asked a million times, just hoping for some insight. I'm some-what new to programming and was curious regarding the markings for comments. I understand that just like Javascript, // is for single line comments and /* */ is for multiline comments. My question is, can I use /* */ for single line comments as well? And is it detrimental towards me/my coding to do that or is it still acceptable? I appreciate any insight into this, and thank everyone for taking the time to read this.

2nd Jun 2018, 11:11 PM
Kyle Moher
Kyle Moher - avatar
5 Answers
+ 5
When working with mutli-line comments, you can generally view them as working with 1+ line(s) in your code. This means that they can be used for only one line if you want. However, I would recommend just sticking with single line comments as they will often provide with a cleaner line as opposed to sandwiching one line of text between two signs, and is often easier to read. Nonetheless, it doesn't really matter too much how you use your comments as it is still your code, and so you can use the multi-line comments for one single line.
2nd Jun 2018, 11:23 PM
Faisal
Faisal - avatar
+ 2
I appreciate the answers. Thanks a bunch! :)
4th Jun 2018, 3:38 AM
Kyle Moher
Kyle Moher - avatar
+ 1
Yes, you can use both styles for single line comments.
4th Jun 2018, 3:37 AM
Hector Herrera
Hector Herrera - avatar
0
Why you don't examine? Look if you always ask for information then your knowladge never gonna be more than someone who is awnsering.
10th Jun 2021, 5:43 AM
Ahmadreza
- 2
do you learn php very well? what is your jab?
3rd Jun 2018, 6:50 AM
Мт99
Мт99 - avatar