Comment is a line of text which is not read and executed as part of the program.
It is used to add notes of the source code or stop some block of code from execution.
When writing a long script it is very helpful by adding comments on each step about what the code does.
If some other using your code or updating then it is easier for the user to understand the working of code and saves time.
In PHP there are two types of comments –
- Single line
1. Single line
You can define single line comment in two ways –
Both do the same work.
If you want to comment more than 1 line then you need to add it to each line.
// Comment text # Comment text
<?php // This is a single line comment # This is a single line comment
With /* */ multi-line comment is added.
/* Comment text */
<?php /* This is multi-line comment block */
With the comment, you can add quick notes on the code and use it for debugging the program.
You can use any of the 3 types of comment methods in your program.If you found this tutorial helpful then don't forget to share.