PHP Comments: Single and multiple lines comments
Comments:
In PHP code, a comment is a line that is neither compiled nor executed. It is a part of the program. And it is only for understanding purposes.
Use of Comments in PHP
- Comments in the source code help us to remember what the code does.
- Think of the situation, where you come back on code after a year later, at that time you can understand the codes through comments, which reminds you of what you have done in code.
- Comments are helpful when multiple programmers are working on the same project.
- Comments are basically the briefing that we include in source code. It is for understanding purposes only.
- There are two types of comments:-
- Single-Line Comments
- Multiple Line Comments
Single Line Comments:-
- It starts with double forward slashes and ends in the same line – “//“
Example:-
<?php // This is single line comments example ?>
Multiple Line Comments:-
- It starts with a forward slash followed by the asterisk and end with the asterisk followed by the forward slash.
/*———
————*/
Example:-
<? php /* This is multiple line Comments Example */ ?>