Coding Standards – Spacing Between Tokens

From: http://www.evolt.org/node/60247

There should always be one space on either side of a token in expressions, statements etc. The only exceptions are commas (which should have one space after, but none before), semi-colons (which should not have spaces on either side if they are at the end of a line, and one space after otherwise). Functions should follow the rules laid out already, i.e. no spaces between the function name and the opening bracket and no space between the brackets and the arguments, but one space between each argument.

Control statements such as if, for, while etc. should have one space on either side of the opening bracket, and one space before the closing bracket. However, individual conditions inside these brackets (e.g. ($i < 9) || ($i > 16)) should not have spaces between their conditions and their opening/closing brackets.

Related posts:

  1. Coding Standards
  2. Use Zen Coding to Speed Up Your Coding
  3. Developing Using Web Standards
  4. What Are Web Standards?
  5. When to Use Margins and When to Use Padding

Leave a Comment

Let us know your thoughts on this post but remember to place nicely folks!