PHP/HTML CGL:
Indention
1 tab
Naming
functions and variables should be as descriptive as possible (even if they become quite long) and be written in lowerCamelCase.
Quotes
Where possible, single qoutes should be used. Using double quotes and "hiding" variables within the string is considered bad practices.
So this is a no go: $foo = "We have $count results";
Use this instead: $foo = 'We have' . $count . 'results';
Concatenation
Concatenations should be done with a spaces before and after the ".".
NO: $foo = 'Blah'.$blubb;
YES: $foo = 'Blah' . $blubb;
Code formatting
Code:
/**
* Short description on what function does
*
* @param string $foo Short description of param if not obvious
* @param array $values Again a short description
* @return bool
*/
function dummyFunctionNameInLowerCamelCase($foo, array $values) {
// some inlne comment
if ($foo === 'bar') {
return TRUE;
} else {
switch ($foo) {
default:
// default should be defined at beginning
foreach ($values as $key => $value) {
if ($value == 'bar') {
return TRUE;
}
}
break;
case 'bar':
// @todo do something
break;
}
}
// booleans should be written in uppercase, so TRUE and FALSE
return FALSE;
}