Changeset 42 for trunk/docs/coding_standards.txt
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/coding_standards.txt
r41 r42 7 7 ====================================================================== 8 8 9 We're following the PEAR coding standards, with minor modifications. 9 We're following the PEAR coding standards, with minor modifications. 10 10 11 11 This is essential reading: … … 20 20 21 21 Auth_SQL.inc.php One PHP Class to be included. The filename is the 22 type of class, underscore, name. Or if in subdirs, 22 type of class, underscore, name. Or if in subdirs, 23 23 this could be /Auth/SQL.inc.php while the class name 24 24 remains "Auth_SQL" … … 29 29 directly in the web root. 30 30 31 script.cli.php A command-line executable script, possibly executed 31 script.cli.php A command-line executable script, possibly executed 32 32 with CRON, usually outputs TEXT, not HTML. 33 33 … … 43 43 44 44 Use an indent of 4 spaces, with no tabs. Code and especially comments should 45 be wrapped <= 80 characters. Exceptions are made in the case where code 45 be wrapped <= 80 characters. Exceptions are made in the case where code 46 46 readability is significantly improved with longer lines. 47 47 … … 80 80 action1; 81 81 break; 82 82 83 83 case 2: 84 84 action2; 85 85 break; 86 86 87 87 default: 88 88 defaultaction; 89 89 break; 90 90 91 91 } 92 92 … … 137 137 ====================================================================== 138 138 139 When functions return boolean values, use 'return false;' or 'return true;' 139 When functions return boolean values, use 'return false;' or 'return true;' 140 140 as opposed to 'return 0;' or 'return 1;' or 'return(-1);'. 141 141 … … 149 149 150 150 $something = $blah . funky() . ".\".=" . $blab; 151 151 152 152 is better than: 153 153 154 154 $something = $blah.funky().".\".=".$blab; 155 155 … … 159 159 ====================================================================== 160 160 161 Use the single quote marks ' to enclose simple strings whenever possible. 162 Double quote marks " require extra parsing and thus slow things down, but 163 are necessary if entities there must be swapped-out such as variables or 161 Use the single quote marks ' to enclose simple strings whenever possible. 162 Double quote marks " require extra parsing and thus slow things down, but 163 are necessary if entities there must be swapped-out such as variables or 164 164 control characters. 165 165 … … 196 196 ====================================================================== 197 197 198 Function comments should follow the Javadoc standard, with detailed 198 Function comments should follow the Javadoc standard, with detailed 199 199 function comments and one-line pointers along the way: 200 200 http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html 201 201 202 202 <?php 203 203 /** … … 215 215 { 216 216 $qid = DB::query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false); 217 217 218 218 $row = mysql_fetch_row($qid); 219 219 if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $match)) { … … 283 283 ====================================================================== 284 284 285 All HTML should be valid XHTML 1.0 verfied with the 285 All HTML should be valid XHTML 1.0 verfied with the 286 286 W3C Markup Validation Service: http://validator.w3.org/ 287 287 … … 302 302 <td nowrap="nowrap">Example</td> 303 303 304 All tags must be properly closed. Tags without a closing part must follow the 304 All tags must be properly closed. Tags without a closing part must follow the 305 305 XHTML convention and end with a space and a slash: 306 306
Note: See TracChangeset
for help on using the changeset viewer.