Documentation

Features

Differences

This shows you the differences between the selected revision and the current version of the page.

docs:coding_standards 2008/08/23 17:57 docs:coding_standards 2008/08/25 07:14 current
Line 25: Line 25:
For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response. For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.
-===== Indentation =====+===== Brackets and Indentations =====
-Indentation should consist of 1 tab.+You should indent your code with 1 tab. 
 + 
 +Opening brackets should start on the next line as the keyword, closing bracket should be aligned below the first letter of the starting keyword. Eg: 
 + 
 +<code php> 
 +if ($foo == "bar") 
 +
 +  call_bar(); 
 +
 +elseif($foo == "baz") 
 +
 +  call_baz(); 
 +
 +else 
 +
 +  call_other(); 
 +
 + 
 +</code>
===== Line Termination ===== ===== Line Termination =====
Line 45: Line 63:
Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted
-<code php> 
-if ($a != 2)  
-{ 
-  $a = 2; 
-}  
-elseif ($a == 3)  
-{ 
-  $a = 4; 
-}  
-else  
-{ 
-  $a = 7; 
-} 
-</code> 

Have more questions? Visit our community forums.