| Version 1 (modified by peter, 3 years ago) |
|---|
Functions and variables
Functions and variables should be named using lowercase, and words should be separated with an underscore. Functions should in addition have the grouping/module name as a prefix, to avoid name collisions between modules. Constants
Constants should always be all-uppercase, with underscores to separate words. This includes pre-defined PHP constants like TRUE, FALSE, and NULL. Module-defined constant names should also be prefixed by an uppercase spelling of the module they are defined by.
Global Variables
If you need to define global variables, their name should start with a single underscore followed by the module/theme name and another underscore.
Classes
Classes should be named using "CamelCase." For example:
<?php
abstract class DatabaseConnection extends PDO {
?>
Class methods and properties should use "lowerCamelCase":
<?php public $lastStatement; ?>
The use of private class methods and properties should be avoided -- use protected instead, so that another class could extend your class and change the method if necessary. Protected (and public) methods and properties should not use an underscore prefix, as was common in PHP 4-era code.
For more information on class and OO standards, see the more detailed coverage. File names
All documentation files should have the file name extension ".txt" to make viewing them on Windows systems easier. Also, the file names for such files should be all-caps (e.g. README.txt instead of readme.txt) while the extension itself is all-lowercase (i.e. txt instead of TXT).
