14.2.1. Indentation

[Important] Important

Use an indent width of 2 characters and a tab width of 8 characters.

Do not use "Soft (emulated with spaces) tabs".

Indent classes, functions, loops and if statements properly. This allows to use jEdit folding.

Example 4. Loop indentation

foreach($arrNames as $strName) {
  echo $strName;
}

Example 5. If indentation

if($strValue == $strValue2) {
  echo 'Values are equal.';
} else {
  echo 'Values are not equal.';
}

Classes should be properly indented and commented in a way that is compatible with doxygen:

Example 6. Class indentation

class Test {
  /**
   * A member variable.
   */
  $strTestName;
  
  /**
   * Test function.
   * @param $strName A name to be passed to the constructor.
   * @return The object.
   */
  function Test($strName) {
    $strTestName = strName;
  }	  
}

Example 7. Switch indentation

switch($intValue) {
  case 1:
    $intResult = 2;
  break;
  default:
    $intResult = 1;
  break;
}

Separate arguments in function calls by a comma and a space.

Example 8. Argument separation

$strMessage = sprintf('This is a %s', 'test');