PHP Comments play a very important role in this language, to know about this 1st we know what is comments.
The part of the source code in a programming file, which is not executable by a compiler called Comments.
Basically, comments are used for:
- To make the reader understand by describing the action of a statement, just like
$a += 07; // Increment $a by 07
- Another good way is to temporarily hide the statement of the code that is giving the errors, like
// echo “Value equals $x”;
In PHP there are two common ways to add comments in the PHP programming file.
SINGLE LINE COMMENT:-
A single line or a statement of code can be turned into a comment by
preceding it with a pair of forwarding slashes.
// This is a single-line comment
<title>PHP Single line Comment</title>
$x = 07;
// Display variables value
A set of statements in a programming file that you want to hide from the compiler by using the /* and */ pairs of characters to open and close comments anywhere inside the file.
/* This is a section
of multi-line comments
which will not be
<title>PHP Multi-line Comment</title>
$x = 07;
/*After assigning the
digit 7 to variable “x” now
it will be displayed on the
Click to know, What is PHP Variables.