Any good programmer will tell you that adding comments to your code can be extremely useful. Since you are on your way to becoming a PHP programmer, it is wise to heed the advice of other programmers.
Comments in your code do nothing to the script itself. Their main purpose is to help you understand why you did something. PHP supports three methods of adding comments to your code: #, // and /* */.
Below are all valid methods of commenting your PHP scripts.
# This comment uses the hash sign to begin a comment // This comment uses two slash marks to begin a comment
/* This chunk of text
will be ignored by PHP. */
You can also use comments at the end of statement:
echo "Hello PHP user"; // This is a vaild comment as well
Comments are also good for adding a description of what the script does, the creator, version numbers, etc...
/* Filename: user.php Description: This script allows visitors to register on this site. Creator: Brandon Version: 1.0 Copyright: GPL 2 */
Comments
Post new comment