Coding Conventions
WebTemplate uses the PEAR 1 coding standard (except it uses 2 spaces for indentation instead of 4). it can be found here:
The basic rules are:
-
use longhand php tags <?php and ?>, not shorthand php tags <? ?>
-
indent of 2 spaces, no tabs
-
braces always required for conditional statements
-
open brace on same line as conditional statement
eg:
if ($condition1) {
doStuff();
} else {
doOtherStuff();
}
-
open brace on separate line to class or function definition
eg:
class ClassName
{
function functionName()
{
}
}
-
Camel Caps for class, variable and function names.
-
Class begin with an uppercase letter, function and variable names begin with a lowercase letter.
-
Member variables begin with m_
eg: m_guid
-
Global variables and constants all in caps and begin with WT
-
eg: $GLOBALS["WTSITEID"]