PHP Coding Standards

  • Make names fit
  • Avoid uppercase abbreviations
  • use common terms like max, cnt, key, is, get, set
  • follow PSR-2 for naming conventions
  • classes - start with uppercase letter, and show have a prefix of 3-4 letters followed by an underscore to prevent naming conflicts
  • Constants - all uppercase, words separated by _ underscore.
  • Variable names - should be in camel case or use _ (underbars)
  • Function names - C GNU conventions of all lower case with underbar as the word delimiter
  • Indent - four spaces for each level
  • Declaration blocks, all declarations should be aligned

Additional ways to standardize your code:

  • Array element - underbar
  • global variables - prepand with 'g'
  • static variables - prepend with 's'

Gotcha Keywords

:TODO: topic
:BUG: [bugId] topic
:KLUDGE:
:TRICKY:
:WARNING"
:ATTRIBUTE: value

This page contains information I gathered and thought were very useful. See more notes on programming.

Just to let you know, this page was last updated Tuesday, Aug 20 19