How to write comments in PHP

Comments are generally written in the block of PHP code to describe the functionality of the code. It will help you and others in the future to know what you were trying to do with the PHP code. Comments won’t be displayed within the output.

There are two types of Comments:

  • Single Line Comments
  • Multi-Line Comments

Single Line Comments

PHP single line comment starts with //, Get the Code below:

echo "Hello World!"; // Output "Hello World!"

Multi-Line Comments

PHP multi-line line comment starts with /*, and ends with */.

/* The following line of code
will output the "Hello World!" message */
echo "Hello World!";



Praveen Kumar

I am a fullstack web developer with a passion for SEO, creating stunning websites, and organic marketing. I am a perfectionist.

Post navigation