This article, among other things will show you how to comment code. You should learn the habit of writing comments in your code now! Commenting allows you to look at your code at a later date and understand what you were getting your code to do. After we have commented your code we’ll execute it!
/* Comments */
PHP comments are like HTML comments. PHP comments are indicated by certain characters, when the PHP code is parsed the text between the commenting characters will not be executed.
You should always comment your code! It is a way of documenting your code that will allow you to understand what your code does! Do you think you will remember what all your code does a few months from now?
To distinguish comments from code use either, // at the start of each line, or enclose the section of test you want as a comment with /* and */
For example:
// This is a comment. Below,
// is another comment.
echo ‘I will be output in the browser’;
/* I am a comment that
is spread across lines */
?>
Getting Your Hands Dirty!
No doubt you have probably skimmed through the above text and are eager/apathetic (you choose) to get coding some PHP scripts!
Begin by writing the following code in an empty .php file. Write what you like inside the quotation marks. Echo outputs what is inside the quotation marks to the web browser when you execute the script:
<?php
echo “This is my first script”;
?>