How to Write Comment in PHP (Single and Multiline)

Last Updated on December 30, 2020 by Roshan Parihar

In this tutorial, learn how to write comment in PHP including single line and multiline. The short answer is: use the symbol // for single line and /* */ for multiline comments.

How to Write Comment in PHP

Using comments in your PHP coding is the best practice for PHP coders and developers to create applications using PHP. It helps you easily understand the purpose of each line of code in just a single view.

So, let’s find out how you can create and add comments using PHP.

PHP Single Line Comment

There two symbols # or // you have to use any one of them at the start of the line of code to make it commented. It’s the simplest way of commenting out a line of code or put a comments at the end of each line to describe the purpose of the line.

Output

Welcome to TutorialDeep!
How are you today?

PHP Multi-Line Comment

You can use PHP multiline comments system to comment out more than one line. Use the start symbol /* to start the comment and the end symbol *\ to the end of the comment to create a multiline comment.

Output

Welcome to Tutorialdeep!

The above example contains the multiline comment that is not visible in the output. You can add as many lines in the multiline comment starting /* and ending *\ tag.

You must also read.