PHP Comments

PHP Comments is one of the most important parts of the code. By using comments, the developer can easily understand the code. These comments are simply a description of the PHP script or code. PHP comments don’t affect the code.
In HTML, we see there is only one type of comment. While PHP has two types of comments i.e.

  • Single Line Comment
  • Multiple Line Comment

Single line comment

The Single-line comments are used to tell the developer to ignore everything which comes to the right side of that syntax of single-line comment.
We can use single-line comments by the following two ways:

  • //
  • #

There is no need to end the single-line comment.

echo "Hello World!"; // This is single line comment
#This is also a single line comment

Live Example:

Tutorials Class - Output Window

Hello World!

Multiple line comment

The Multiple PHP comment can be used to comment out large blocks of code(we can even comment paragraphs in PHP script).
The multiple line PHP comment begins with /* and ends with */.We must end the multiple line comment.

/* This is a multiple line comment 
here we print Hello World statement */
echo "Hello World!";

live Example:

Tutorials Class - Output Window

Hello World!

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is single line comment in PHP? Explain with syntax.