By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Comments in PHP

How to write comments in PHP. You can either write single line comments and multiline comments, this Reference cover both methods.

Created: 2012-02-25 17:43

How to write Comments in PHP. To write a single line comment, you can use two dashes //, followed by one or more spaces and the comment it self.

You can also write multi line comments, this is done by using a opening /* and closing */ set of dashes and asterisks. Multi line comments can be used for larger blocks of text, such as copyright or contact information of the script author.

The below example comments can be used for reference purposes.

  This is a multi line comment in php
if ($somevar) { // This is a Comment in php
 // This is another PHP Comment
 echo 'true';