H-129, Palri, Hodal, Palwal, HR
+91 9992755268

PHP Comments

 

PHP Comments

there are two types of  PHP comments are as follows:

  1. single line Comments
  2. multiline Comments

Using Comments
There are two ways in which you can add PHP comments to your PHP code. The first turns
a single line into a comment by preceding it with a pair of forwarding slashes, like this:

// This is a comment

This version of the comment feature is a great way to temporarily remove a line of code
from a program that is giving you errors. For example, you could use such a comment
to hide a debugging line of code until you need it, like this:

// echo "X equals $x";

You can also use this type of comment directly from a line of code to describe its action,
like this:

$x += 10; // Increment $x by 10

When you need multiple-line comments, there’s a second type of comment, which looks
like Example 3-2.

Example 3-2. A multiline comment

<?php
/* This is a section
of multiline comments
which will not be
interpreted */
?>

You can use the /* and */ pairs of characters to open and close comments almost
anywhere you like inside your code. Most, if not all, programmers use this construct to
temporarily comment out entire sections of code that do not work or that, for one reason
or another, they do not wish to be interpreted.

A common error is to use /* and */ to comment out a large sec‐
tion of code that already contains a commented-out section that uses
those characters. You can’t nest comments this way; the PHP inter‐
preter won’t know where a comment ends and will display an error
message. However, if you use a program editor or IDE with syntax
highlighting, this type of error is easier to spot

<< PrevNext >>