8.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.");
}

Example 6. Class indentation

class Test {
  // store the name
  $strTestName;
  
  // constructor
  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");