Adding Comments
A comment in PHP code is a line that is not executed as a part of the program. Its only purpose is to be read by someone who is looking at the code.
Comments can be used to:
•Let others understand your code
•Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code
•Leave out some parts of your code
Example: 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 */
Format Samples
//======================================================================
// CATEGORY LARGE FONT
//======================================================================
//====================//
// CATEGORY LARGE FONT //
//====================//
//-----------------------------------------------------
// Sub-Category Smaller Font
//-----------------------------------------------------
//--------------------------------------//
// Sub-Category Smaller Font //
//--------------------------------------//
/* Title Here Notice the First Letters are Capitalized */
# Option 1
# Option 2
# Option 3
/*
* This is a detailed explanation
* of something that should require
* several paragraphs of information.
*/
// This is a single line quote.
Summary
Rule 1: Comments should not duplicate the code.
Rule 2: Good comments do not excuse unclear code.
Rule 3: If you can't write a clear comment, there may be a problem with the code.
Rule 4: Comments should dispel confusion, not cause it.
Rule 5: Explain unidiomatic code in comments.
Rule 6: Provide links to the original source of copied code.
Rule 7: Include links to external references where they will be most helpful.
Rule 8: Add comments when fixing bugs.
Rule 9: Use comments to mark incomplete implementations.