g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Natural Living
Folklore and Mythology
Distance Learning

All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g PHP Site

BellaOnline's PHP Editor


How To Add Comments To Your PHP Program

Guest Author - Diane Cipollo

Every programmer has his or her opinion as to what information should be included with the program code. Most programmers add comments with their code in order to remind themselves, and anyone else, what the code does and how it does it. When deciding what information to include ask yourself what you would need to be told about the program if someone else had written the program and now you were asked to run and maintain it.

Most of the programs that you write will have more than one page of code. Each page of code will be saved as a PHP program file. (filename.php3) There are two places in the program file where you will want to add some informational comments.

  1. At the top of each program file you will include general information about the program.

    • At the very top of the file and just after the opening PHP tag you will put the name of the file such as HelloWorld.php3.
    • Next you will add a copyright notice naming yourself as the copyright owner of the program.
    • If your program will have more than one page of code, you will mention that this is one page of a larger program and give the name of that program.
    • You will also want to include a brief description of the purpose of the program and how it works.
    • Last you will add any disclaimer and licensing information. For example this could be a license written by your lawyer or the GNU General Public License which you are free to use on any of your freeware programs. You can download a copy of this license from the Free Software Foundation website. We will discuss this in more detail in a separate tutorial.

  2. The second area where you will want to add comments is throughout the code itself at the beginning of each major section of code. Include a short comment about what task that particular section will perform.
There are three ways to add comments to your program code.

// comments go here
This is the basic PHP style comment. Anything on the same line and that comes after the two // will be ignored by the server and not processed as program code.

# comments go here
This is the shell-style comment. Anything on the same line and that comes after the # will be ignored by the server and not processed as program code.

comments go here
comments go here
comments go here
This is the C-style comment. Anything that is between the opening /* and the closing */ will be ignored by the server and not processed as program code. You can use this style when you have more than one line of comments such as we have discussed in this tutorial. Click here for an example.

This site needs an editor - click to learn more!

Add How+To+Add+Comments+To+Your+PHP+Program to Twitter Add How+To+Add+Comments+To+Your+PHP+Program to Facebook Add How+To+Add+Comments+To+Your+PHP+Program to MySpace Add How+To+Add+Comments+To+Your+PHP+Program to Digg How+To+Add+Comments+To+Your+PHP+Program Add How+To+Add+Comments+To+Your+PHP+Program to Yahoo My Web Add How+To+Add+Comments+To+Your+PHP+Program to Google Bookmarks Add How+To+Add+Comments+To+Your+PHP+Program to Stumbleupon Add How+To+Add+Comments+To+Your+PHP+Program to Reddit

RSS | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the PHP Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2018 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.


g features
Archives | Site Map


Past Issues

Note: BellaOnline uses cookies to help provide a consistent user experience. Our advertisers may use cookies to help customize ads. Please contact us with any question about our cookie use.

Summertime Foods
Corn on the Cob
Burgers on the Grill
Apple Pie


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2018 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor