Coding Standards
PHP
phpWebSite has adopted the PEAR PHP coding standards with a few addedums regarding HTML/XHTML markup, file headers, comment styles, etc.
The PEAR Standards can be found at:
http://pear.php.net/ma...n/standards.php
Exceptions to the PEAR standards
Addendum to PEAR Standards Regarding Markup (Adapted from the BinaryCloud Standards):
- Declare all of your variables at the top, right under the function. Don't get globals, etc inside the code. In other words, do all of your setup at the top of the file.
- It is nice if comments are wrapped to 80 chars, you'll probably get in the habit anyway - but it is not necessary. Tags cannot and should not be wrapped to 80 chars. Note that this standard applies to all markup: html, xhtml, wml, xml, etc.
- Keep Template files free of php code.
- Use html comments _ONLY_ when you are printing html. If the comment is about PHP code, use PHP comments. The purpose of the html comments is to allow html authors to locate code embedded in complex pages, so they can fix it easily. Diagnostic information is the only exception.
