Short introduction to code comments in PHP.

Though many seem to ignore them, comments are very important in coding. Maybe not yet, but later on, you will see that you will need some kind of “bookmarks” throughout your code, and comments are exactly what you need.
Basically, code comments are notes, shorter or longer texts which are ignored by the parser or compiler, (PHP parser on the server in this case), but are really useful in code documentation for the humans reading the code.
There are two main types of code comments: line comments and block comments;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php // commented line - read on this line is out of the comment and will be parsed # while this is another way to comment lines of code. and this is out of the comment // while this is commented /* this is a block comment which can spread on several lines */ ?> |
Line comments
Are done with two “/” next to each other (ex: “//“), or with the character “#“. Everything after // or # on that line will be ignored by the parser.
Block comments
are opened with “/*” and closed with “*/“, and everything in between, no matter how many lines, is ignored by the parser.




