Changeset 293 for trunk/docs


Ignore:
Timestamp:
Dec 11, 2007 10:53:46 PM (16 years ago)
Author:
quinn
Message:

Minor updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/coding_standards.txt

    r247 r293  
    1414
    1515======================================================================
    16 File naming conventions
     16File Naming Conventions
    1717======================================================================
    1818
     
    3232                        with CRON. Outputs TEXT if any instead of HTML.
    3333
     34script.inc.eml          Text file to be sent by email.
     35
    3436schema.mysql            Database schema file that goes with the application.
    3537
     
    3941
    4042======================================================================
    41 Indenting and wrap
     43Indenting and Wrap
    4244======================================================================
    4345
    4446Use 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.
     47usually be wrapped <= 80 characters. Exceptions are made in the case where
     48code readability is significantly improved with longer lines.
    4749
    4850
     
    113115
    114116======================================================================
    115 Function Definitions
     117Function and Method Definitions
    116118======================================================================
    117119
     
    129131attempt to return a meaningful value from a function if one is appropriate.
    130132
    131 Recommend using studlyCaps for function names, to distinguish from php
    132 internal functions which standard on under_score_space() style names.
    133 
    134 
    135 ======================================================================
    136 Return values
     133Use lowerCamelCase for function and method names to distinguish from php
     134internal functions which standard on underscore_space_style_names().
     135
     136
     137======================================================================
     138Return Values
    137139======================================================================
    138140
    139141When 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
     142as opposed to 'return 0;' or 'return 1;' or 'return(-1);', except when
     143boolean plurality is necessary.
     144
     145
     146======================================================================
     147String Concatenation
    145148======================================================================
    146149
     
    156159
    157160======================================================================
    158 Quote marks
     161Quote Marks
    159162======================================================================
    160163
     
    164167control characters.
    165168
    166         $var['singlequote'] = 'singlequote';
    167         $var["doublequote-$i"] = "$vars and \n funny \t %s things need doublequotes";
    168         $var['doublequote-' . $i] = $var . 'you can do this' . "\t %s" . $var2 .
    169         'but it isn\'t any better';
    170 
    171 
    172 ======================================================================
    173 Printing html
     169    $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======================================================================
     176Printing HTML
    174177======================================================================
    175178
     
    179182
    180183    <?php
    181     if (something) {
    182         // Here comes the HTML...
     184    if ($something) {
     185        // Here comes multi-line HTML...
    183186        ?>
    184187        <div class="sc-tiny">
     
    186189        </div>
    187190        <?php
    188     } else if (somethingelse) {
    189         ?><h1>Just a little html</h1><?php
     191    } else if ($somethingelse) {
     192        ?><h1>Just a single-line of html</h1><?php
    190193    }
    191194    ?>
     
    271274======================================================================
    272275
    273 ALWAYS use <?php ?> to delimit PHP code, not the <?php ?> shorthand. Even
    274 use <?php echo $name ?> instead of <?php echo $name; ?>.
    275 
    276 
    277 ======================================================================
    278 php.ini settings
     276Always use <?php ?> to delimit PHP code, not the <? ?> shorthand. Even
     277use <?php echo $name; ?> instead of <?=$name?>.
     278
     279
     280======================================================================
     281php.ini Settings
    279282======================================================================
    280283
    281284All 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, and environment data, respectively.
     285$_REQUEST, $_GET, $_POST, $_COOKIE, $_SESSION, $_SERVER, and $_ENV
     286to access all request, get, post, cookie, session, server, and
     287environment data, respectively.
    285288
    286289All code should work with error_reporting = E_ALL. Failure to do so would
     
    289292
    290293All code should work regardless of the setting of magic_quotes_gpc.
    291 Form data should be passed through stripslashes if necessary.
     294Form data should be passed through stripslashes() if necessary.
    292295
    293296No code should assume that '.' is in the include path. Always
    294297specify './' in front of a filename when you are including a file in
    295 the same directory.
     298the same directory. Or better yet, for less abiguity, use:
     299include dirname(__FILE__) . '/include_me.inc.php';
    296300
    297301
     
    300304======================================================================
    301305
    302 All HTML should be valid XHTML 1.0 verfied with the
     306All HTML should be valid XHTML 1.0 verified with the
    303307W3C Markup Validation Service: http://validator.w3.org/
    304308
Note: See TracChangeset for help on using the changeset viewer.