We encourage ActionApps developers to follow the coding standards described bellow. It help us to have the code as readable as possible for everyone.
Most of the following rules comes from php PEAR standard http://pear.php.net/manual/en/standards.php
Most important rules on tne top:
If we mix both modes, the CVS diffs are unusefull
Do not use Tabs or use 'insert Tabs as spaces' option of your text editor. Most of the editors (like Jedit or HomeSite) allows it. Then the code will look good in any editor.
Do not use any other shorted version like <?, .. There are some problems on some Apache configurations with <?...
See http://phpdocu.sourceforge.net/
- use /* */
and //
for comments, not #
- open brace at the end of line
if ((condition1) || (condition2)) {
commands;
} else {
commands;
}
- if
, while
, ... separated by space (it is not function call)
function($var1, $var2=true)
No space between function name and open brace allow us easier find the function in the code.
Try to write the code 80 characters wide, if possible.
Allways qoute strings like
'name'
in $arr['name']
or $db->f('name')
although current PHP do not need it.
$_GET
, $POST
, and $_SERVER
Use mentioned superglobal arrays to access variables from forms ...
Return is the statement, not a function.
I know the current code do not strictly follows mentioned rules, but from this time it will ....... hopefully
Honza Malik, 1/29/2003