Coding guidelines
The following wrong guideline examples will result in notices about undefined variables.
Wrong
if ($_GET["id"]) {
...
}
Right
if (isset($_GET["id"])) {
...
}
Defining constantsWrong
define(TABLE_USERS, "fundausers");Right
define("TABLE_USERS", "fundausers");
Checking if a variable contains dataWrong
if ($_GET["name"] != "") {
...
}
Right
if (!empty($_GET["name"])) {
...
}
Purely visual
Argument listWrong
doSomething("title text",1,200,getData());
Right
doSomething("title text", 1, 200, getData());
Seperate arguments by a space.Ternary conditional operator
Wrong
$a = ($b)?$c:$d;Right
$a = $b ? $c : $d;Again spaces makes it easier to read the code and structure.
Miscellaneous
If statements requries brachets even though they only have one line statements.
Indenting is done using 4 spaces instead of tabs. Emacs and Vim setup for this.