Changeset 293 for trunk/docs
- Timestamp:
- Dec 11, 2007 10:53:46 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/coding_standards.txt
r247 r293 14 14 15 15 ====================================================================== 16 File naming conventions16 File Naming Conventions 17 17 ====================================================================== 18 18 … … 32 32 with CRON. Outputs TEXT if any instead of HTML. 33 33 34 script.inc.eml Text file to be sent by email. 35 34 36 schema.mysql Database schema file that goes with the application. 35 37 … … 39 41 40 42 ====================================================================== 41 Indenting and wrap43 Indenting and Wrap 42 44 ====================================================================== 43 45 44 46 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 46 readability is significantly improved with longer lines.47 usually be wrapped <= 80 characters. Exceptions are made in the case where 48 code readability is significantly improved with longer lines. 47 49 48 50 … … 113 115 114 116 ====================================================================== 115 Function Definitions117 Function and Method Definitions 116 118 ====================================================================== 117 119 … … 129 131 attempt to return a meaningful value from a function if one is appropriate. 130 132 131 Recommend using studlyCaps for function names,to distinguish from php132 internal functions which standard on under _score_space() style names.133 134 135 ====================================================================== 136 Return values133 Use lowerCamelCase for function and method names to distinguish from php 134 internal functions which standard on underscore_space_style_names(). 135 136 137 ====================================================================== 138 Return Values 137 139 ====================================================================== 138 140 139 141 When functions return boolean values, use 'return false;' or 'return true;' 140 as opposed to 'return 0;' or 'return 1;' or 'return(-1);'. 141 142 143 ====================================================================== 144 String concatenation 142 as opposed to 'return 0;' or 'return 1;' or 'return(-1);', except when 143 boolean plurality is necessary. 144 145 146 ====================================================================== 147 String Concatenation 145 148 ====================================================================== 146 149 … … 156 159 157 160 ====================================================================== 158 Quote marks161 Quote Marks 159 162 ====================================================================== 160 163 … … 164 167 control characters. 165 168 166 167 168 169 170 171 172 ====================================================================== 173 Printing html169 $var['singlequote'] = 'singlequote'; 170 $var["doublequote-$i"] = "$vars and \n funny \t %s things need doublequotes"; 171 $var['doublequote-' . $i] = $var . 'you can do this' . "\t %s" . $var2 . 172 'but it isn\'t any better'; 173 174 175 ====================================================================== 176 Printing HTML 174 177 ====================================================================== 175 178 … … 179 182 180 183 <?php 181 if ( something) {182 // Here comes the HTML...184 if ($something) { 185 // Here comes multi-line HTML... 183 186 ?> 184 187 <div class="sc-tiny"> … … 186 189 </div> 187 190 <?php 188 } else if ( somethingelse) {189 ?><h1>Just a littlehtml</h1><?php191 } else if ($somethingelse) { 192 ?><h1>Just a single-line of html</h1><?php 190 193 } 191 194 ?> … … 271 274 ====================================================================== 272 275 273 A LWAYS use <?php ?> to delimit PHP code, not the <?php?> shorthand. Even274 use <?php echo $name ?> instead of <?php echo $name;?>.275 276 277 ====================================================================== 278 php.ini settings276 Always use <?php ?> to delimit PHP code, not the <? ?> shorthand. Even 277 use <?php echo $name; ?> instead of <?=$name?>. 278 279 280 ====================================================================== 281 php.ini Settings 279 282 ====================================================================== 280 283 281 284 All code should work with register_globals = Off. This means using 282 $_ GET, $_POST, $_COOKIE, $_SESSION,283 $_SERVER, and $_ENV to access all get, post, cookie, 284 session, server, andenvironment data, respectively.285 $_REQUEST, $_GET, $_POST, $_COOKIE, $_SESSION, $_SERVER, and $_ENV 286 to access all request, get, post, cookie, session, server, and 287 environment data, respectively. 285 288 286 289 All code should work with error_reporting = E_ALL. Failure to do so would … … 289 292 290 293 All code should work regardless of the setting of magic_quotes_gpc. 291 Form data should be passed through stripslashes if necessary.294 Form data should be passed through stripslashes() if necessary. 292 295 293 296 No code should assume that '.' is in the include path. Always 294 297 specify './' in front of a filename when you are including a file in 295 the same directory. 298 the same directory. Or better yet, for less abiguity, use: 299 include dirname(__FILE__) . '/include_me.inc.php'; 296 300 297 301 … … 300 304 ====================================================================== 301 305 302 All HTML should be valid XHTML 1.0 ver fied with the306 All HTML should be valid XHTML 1.0 verified with the 303 307 W3C Markup Validation Service: http://validator.w3.org/ 304 308
Note: See TracChangeset
for help on using the changeset viewer.