| » Indenting |
| All the codes will be indented properly (indent of 4 spaces, with no tabs) |
| |
| » Control Structures |
| These include if, for, while, switch, etc. Here is an example if statement, since it is the most complicated of them:
<?php
if ((condition1) || (condition2)) {
action1;
} elseif ((condition3) && (condition4)) {
action2;
} else {
default action;
}
?>
Control statements will have one space between the control keyword and opening parenthesis, to distinguish them from function calls.
Curly braces will always be used even in situations where they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.
|
| |
| » Function Calls |
Functions will be called with no spaces between the function name, the opening parenthesis, and the first parameter; spaces between commas and each parameter, and no space between the last parameter, the closing parenthesis, and the semicolon. Here's an example:
<?php
$var = foo($bar, $baz, $quux);
?> |
| |
| » Comments |
Inline documentation comment blocks will be provided near the codes, which are complex & would need detailed explanation on what it does or it is meant for.
C style comments (/* */) and standard C++ comments (//) will be used. |
| |
| » Naming Conventions |
Classes : Classes will be given a descriptive names. Class names will always begin with an uppercase letter.
Examples of good class names are:
Log
Net_Finger
HTML_Upload_Error
|
| |
| » Functions and Methods |
|
Functions and methods will be be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). Functions in addition will have the package name as a prefix, to avoid name collisions between packages. The initial letter of the name (after the prefix) is lowercase, and each letter that starts a new "word" is capitalized. Some examples:
connect()
getData()
buildSomeWidget()
XML_RPC_serializeData()
|
| |
| » Constants |
|
Constants will always be all uppercase, with underscores to separate words.
|