tbrehm
2007-10-24 03ade50f9f1826fbe3c21de9cc37fafb7aec8478
commit | author | age
b64955 1 Some guidelines for web development with php.
P 2 -----------------------------------------------------
316369 3 * Unix Line Breaks Only, NO windows breaks please.
P 4 * Tabs set at 4 spaces either as tabs or spaces.
5 * no accidental _<?php space before, within or after a file
6 * every php file starts and end with <?php ?> no spaces before or after
7 * error_reporting(E_ALL|E_STRICT) , yep php5
8 * Magic quotes is gone in php6, get used to it now. config = magic_quotes_gpc() Everything must be quoted
b64955 9
316369 10 please mark any section that nned review or work on with
P 11 // TODO 
b64955 12
P 13 Pear coding guiidelines
14
15 //*****************************************************************************
16 // Commenting style
17 //*****************************************************************************
18 phpdoc is used for creating and autogenerating the documentation, this means that
19 some of the comments can be formatted to be included in documentation.
20 ie the source files are scanned then processed and html docs are created. 
21
22 The comments break down into the following types
23 // is uses for removing lines and debug dev etc
24 //** and //* are used as "sub comments"
25 /* 
26     is used to comment out blocks
27 */
28 /** is used to create documentaion
29 * thats over 
30 * lines
31 */
32
33 If you need to block out a section then use
34 /*
35 function redundant_code(){
36     something here
37 }
38 */
39
40 To block out single lines use // and all // are assumed to be redundant test code and NOT comments
41
42 // print_r($foo);
43
44 For incline comment use //** and //* eg
45
46 //** Decide what do do
47 switch($decide){
48     //* blow it up
49     case 'baloon':
50         $foo->gas(+1);
51         // test_pressure(); << inline comment
52         break;
53
54     //* Do default action
55     default:
56         do_land();
57         get_gps();
58         //* following grant greaceful exit
59         //basket_exit_crash();
60         basket_exit();
61
62 }
63
64 Do not use the phpdoc on every function, eg 
65
66 /**
67 * Login an user
68 * @param string user  username
69 * @param string password of user
70 */
71 >>
72 function login($user, $pass){
73 .......
74 }
75 <<
76 as this function explains its self, the followinf clean code will suffice
77 >>
78 function login($user, $pass){
79 .......
80 }
81
82 If you do need to explain a function then put un the summary syntax eg
83
84 /** Pass an array of values where third param is bar
85 * $foo['bar'] = 1; // allow an user
86 * $foo['bar'] = 2; // destroy user
87 * $foo['bar'] = -1; // recreate
88 */
89 public function do_something($x, $y, $foo){
90 ... do something interesting    
91 }
92
93
94