Changes

Commenting PHP Code

1 byte added, 14:00, 13 May 2009
no edit summary
When programming in any language the process of adding comments involves writing notes alongside the code to describe what the code does and how it works. The comments are ignored by the PHP pre-processor when executing a script and are purely for human consumption.
Commenting of code is often neglected by software developers. Sometimes this is because the code is being developed to meet a looming deadline and there is no time to adequately comment it. Often there is a tendancy tendency on the part of the developers to believe that they will remember how the code works six months or a year from now. Another common excuse for not commenting is that the code is so well written as to be completely self-explanatory.
Excuses aside, there is much to be gained from included helpful and concise comments with the PHP code that powers your web site. Firstly, you will be amazed at how puzzling a section of code can be even a few months after you have written it. It is not unusual for a developer to revisit some old code they once wrote and express amazement that they actually wrote it. It is important to remember that there is a good chance you will have to continue to maintain your PHP scripts long after they are written.
== PHP Single Line Comments ==
Comments that reside on a single line are prefixed with the two forward slash characters in PHP (i.e . ''//'').
The following example contains a single line comment: