X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

PHP Comments

The PHP comment always begins with unique characters and all text that appears between the comment will be ignored.

There are two types of comments.

  • Single line comment
  • Multiple line comment

Single line comment - will begin with "\\" or "#" symbols, and all text on right will be ignored !

<?php

   echo "Hello W3docs!";

   // This will output Hello W3docs!


  // echo "This is comment!";  (This will not output)


  # echo "This is a comment, too !";  (This will not output)

?>

Multiple line comment - begins with " /* " and ends with " */ " , and all text between that symbols will be ignored.

<?php

  /*  This is multiple line comments

   and all this text will be ignored  */

?>

Nested comments are not allowed , and will cause an error !

<?php

  /*  This is multiple line comments

  /* This comment is not allowed */

   and all this text will be ignored  */

?>



Do you find this helpful?

Related articles