In all my time coding php I have read a lot of php coding standards.
Finally I have found one that I almost agree with completely. My only wobble is regarding the suggestion not to use getters and setters in classes.
The PHP Coding Standard is with permission based on Todd Hoff‘s C++ Coding Standard.
Rewritten for PHP by Fredrik Kristiansen / DB Medialab, Oslo 2000-2003.
I occasionally see code like this:
if ($very_long_condition && $second_very_long_condition)
{
…
}
else if (…)
{
…
}
However I prefer
if ($very_long_condition && $second_very_long_condition){
…
}
else if (…){
…
}
I’m not sure why however it just “feels” right.
Posted by PHP Designer on November 13th, 2008.
@PHP Designer
I always put curly braces on their own line. I do this because php is whitespace tollerant and you can (and should) use as much as needed to make your code readable.
I personally think that
is easier to read than
or
Posted by harrybailey on November 13th, 2008.