PHP supports various methods of commenting:
Syntax for comments in PHP code:
// This is a single-line comment
# This is also a single-line comment
/* This is a
multi-line comment */
Single-line comments begin with //.
Any text following // until the end of the line will be ignored (not executed)
You can also use # for single-line comments, but in this tutorial, we’ll use //.
The following examples demonstrate a single-line comment as an explanation:
A comment preceding the code:
// Outputs a welcome message:echo"Welcome Home!";
A comment at the end of a line:
echo"Welcome Home!";
// Outputs a welcome message
We can use comments to stop certain lines of code from being executed:
Do not show a welcome message.
// echo "Welcome Home!";
|