In PHP, there is a specific character for the initialization of comment. It is used as a memo for others who will check you’re the main codes of the web page. These comments can only be seen by opening the file for alteration.
Code in HTML
Syntax of Comments: Comment is of Single Line:
In PHP, there are two modes of comment. The first one is single line. It explains that the data which is written to right side on that specific line of comment must be ignored. For this purpose, write “//”. You can type “#” also.
echo "HI to all!"; // Hi to all will be printed.
echo "<br />Comment can not be seen!"; // echo "nil";
// echo "My good name is James!";
# echo "I can not do everything” ;
Hi to all!
Comment can not be seen!
Here, it can be seen that some of the statements can not be seen. The reason is that they become ignored due to the presence of single line comment. Such types of comments are used to explain the confusing statement. In this way, you can even make any code inactive for some time.
Syntax of PHP Comment: Several Line Comment
If you have to make comments of many lines then multiple line comment is best for you. The way is just like that of HTML. It starts with the sign “/*” and gets ended with the other sign “*/”.
/* Here, the given echo statement is used to print the message on the very place, where I dwell in.
You can also say that this place is world.*/
echo "Welcome to this world!";
/* echo "My good name is James!";
echo "Not to use! My good name is developer of PHP!";
Welcome to this world!
How to practice the Comments?
If you want to write comments then it is needed to make a lot of practice. I have seen many people who do not use comments. May be they do not feel it necessary. But it will always keep you in touch with your thoughts. Whenever you will check the comment, you will get to know what was in your mind at that time.
Use comments, so that you can get benefits from it. If you have to write short comment then solo line comment will be used. Otherwise, manifold line comment will be used.