canmove, Confirmed users, Bureaucrats and Sysops emeriti
1,043
edits
(→Do) |
m (Update:Archive/2.0/Devleopers/Best Practices moved to Update:Archive/2.0/Developers/Best Practices: typo in page title) |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{AmoArchive}} | |||
== Introduction == | == Introduction == | ||
Line 29: | Line 29: | ||
* Use <?php ?> to designate code blocks | * Use <?php ?> to designate code blocks | ||
* Use CSS for all styles. | * Use CSS for all styles. | ||
* Write in XHTML ? | |||
* Create validated markup according to html 4.01 Strict. | * Create validated markup according to html 4.01 Strict. | ||
* Use $_REQUEST if input could come from GET or POST | * Use $_REQUEST if input could come from GET or POST | ||
Line 38: | Line 39: | ||
* Use variable or function names that are ambiguous (like $var or validate()). | * Use variable or function names that are ambiguous (like $var or validate()). | ||
* Create unnecessary functions. | * Create unnecessary functions. | ||
* Use | * Use <? ?> to designate a PHP block. | ||
* Use $array[foo] or $array["foo"] unless it is appropriate (constant or a variable catted with a string). | * Use $array[foo] or $array["foo"] unless it is appropriate (constant or a variable catted with a string). | ||
* Loop MySQL queries. | * Loop MySQL queries. | ||
Line 45: | Line 46: | ||
* Build URLs including Session ID (''SID should be "automagically" added by PHP if we're using a no-cookie configuration''). | * Build URLs including Session ID (''SID should be "automagically" added by PHP if we're using a no-cookie configuration''). | ||
* Use inline styles. Ever. | * Use inline styles. Ever. | ||
* Use <table> for design | |||
* Duplicate DOM IDs. | * Duplicate DOM IDs. | ||
* Use $_GET and $_POST with extra checks if the input could come from either GET or POST | * Use $_GET and $_POST with extra checks if the input could come from either GET or POST | ||
Line 54: | Line 56: | ||
:Personally, if you want to avoid namespace conflicts, then you should be writing things as classes; so <tt>mozupd_addRating()</tt> becomes <tt>$rating = new Rating(); $rating->addRating();</tt>. I would tend to agree on "internal" methods being called <tt>_methodName</tt> but I think prefixing everything with mozupd_ etc. is going to get extremely annoying very quickly. --[[User:Csogilvie|Csogilvie]] 10:55, 22 Jan 2005 (PST) | :Personally, if you want to avoid namespace conflicts, then you should be writing things as classes; so <tt>mozupd_addRating()</tt> becomes <tt>$rating = new Rating(); $rating->addRating();</tt>. I would tend to agree on "internal" methods being called <tt>_methodName</tt> but I think prefixing everything with mozupd_ etc. is going to get extremely annoying very quickly. --[[User:Csogilvie|Csogilvie]] 10:55, 22 Jan 2005 (PST) | ||
Why not use "umo_" instead? It's much more intuitive to use. | |||
--[[User:Topal|Topal]] 15:13, 16 Apr 2005 (PDT) | |||
If we use classes then there's no need to worry about that. In the cases that there is a chance, simply do something like mozupdate_sendMail() | |||
--[[User:Artooro|artooro]] 17:42, 22 Apr 2005 (EDT) | |||
== Database Calls == | |||
: Please edit this as needed. | |||
Database calls should be in the file /foo/bar.php | |||
To execute the query and get the results, you should use a wrapper of the form: | |||
db_Something(arg1,arg2,arg3) |