r/PHPhelp • u/Tricky_Box_7642 • Dec 16 '25
Solved Difference between comments
JUst wondering, what is the difference between
/* */
and
/** */
10
Upvotes
r/PHPhelp • u/Tricky_Box_7642 • Dec 16 '25
JUst wondering, what is the difference between
/* */
and
/** */
7
u/tom_swiss Dec 16 '25
As far as the PHP language itself is concerned, there's no difference. Some third-party tools to extract documentation from comments use /** ... */ as something meaningful.
7
u/StillScooterTrash Dec 16 '25
The second is used for docblock comments. Docblocks are used to describe a file, class, method, or property in a structured way
See: https://docs.phpdoc.org/guide/getting-started/what-is-a-docblock.html
3
u/itemluminouswadison Dec 16 '25
Two asterisks are a docblock, single asterisk is a comment
Docblocks are on top of units and describe params and return type
2
u/BrianHenryIE Dec 16 '25
is valid too (I learned this year)
Edit: that should be:
# is valid too (I learned this year)
1
u/exqueezemenow Dec 16 '25
One asterisk is a block comment. Two asterisks is a docblock used and read by IDEs, etc. The first one is usually ignored by interpreters and is handy for things like temporarily commenting out code or notes meant only for a human. The two asterisks is for interpreters, etc to read as well as humans.
0
u/Commercial_Echo923 Dec 16 '25
None at all. Everything between /* */ counts as a comment so * is just the comment content.
-4
u/sensasi-delight Dec 16 '25
first is one line comment, second is multiple lines comment
0
u/[deleted] Dec 16 '25
[deleted] — view deleted comment