HOW TO COMMENT OUT YOUR SCRIPT IN PHP
When coding in PHP, it is customary to insert special comments to describe what the codes does or any other useful information. This is especially important if you look back at this script some time later and these comments will instantly tell you what the script or a certain line of code was for.
Comments are embedded in the script itself and co-exist with your actual coding. However, there are certain ways to do this so as not to interfere with the actual execution of your script and cause errors.
Using # or //
<?
echo "John Smith";
# This is a comment line
// This is also a comment line
?>
You can # or // in the same line as your code as below:
<?
echo "John Smith"; # This is a comment line
echo "Nancy Wells"; // This is also a comment line
?>
If you use # or //, a new line of comment must also start with # or // as below:
<?
echo "John Smith"; # This is a comment line that extends
# Over two lines
echo "Nancy Wells"; // This is also a comment line
// that extends Over two lines
?>
A simple method for long comments that extends multiples lines is:
<?
/* This is my first php script to demonstrate comments.
It is very simple to use this method if you
Have long comment lines.
Done by: John Smith
Date: 24 May 2007
*/
echo "John Smith";
?>
If you want to emphasize important comments, use this:
<?
##############################################
##This is my first php script to demonstrate comments.##########
##############################################
echo "John Smith";
?>
|