PHP Coding Guidelines show the Best Practices in PHP Code Style. Using the best practices improves the code quality and maintenance is easier.
A summary of the most important php code guidelines. This are our standards. Feel free to use em and tell us how to improve em.
- Do not use php close tag If you drop the close php tag, the php interpreter won't switch to HTML mode. This way, you won't run into strange session errors.
- Proper Class,Function and Variable Nameing Use CamelCase for Classes. Start with lowercase for Functions and Variables, but do not use underscores, use Capitals instead. Use UPPERCASE for terms like HTTP or JSON. Feel free to use short variable names like $i for loops.
- Proper Indentation Use tabs, ident like writing in python. It improves the readability.
- Comments Above every class and function, write a short line that explains the input parameters (which you name self explaining, talking good is better then comments) and explain the return values. Mention if it throws Exceptions.