PHP Comments

PHP Comments

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 Web!";

   // This will output Hello Web!

  // 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  */

?>
Reactions

Post a Comment

0 Comments

close