PHP Development Guide
Database Connection
Database connection info should be defined in a single file. A typical place, also the Dreamweaver default, is:
/Connections/conn.php
Functions and Modules
To make the site easy to maintain, we use functions to generate page headers and page footers. Only leave out the content part to each individual page.
For a typical New Circle developed website, all major functions are stored in /php-functions.php.
Global Variables and Constants
Global variables and constants are usually stored in /php-constants.php.
Coding and Naming Standards
Variable Name
- Variable name should start with lowercase alphabets.
- Single word variable name should all be lowercase.
$cart
- Multiple words can be connected by underscore “_”. Ie. $admin_email
Coding
- All code should be properly spaced and indented for readability.
- Comments should be added when appropriate for functions, etc.
- Unused code should be removed promptly to avoid confusion.
Typical folder/file structure
| /admin |
All site admin pages should be under this directory |
| /Connections |
for DB connection info |
| /images |
images |
| /inc |
for all stylesheets and javascripts |
| /lib |
If you choose to use PHP object, define the file with object name, cap the first letter, and put in this directory. See "Cart.php" for example |
| /samples |
There is a "samples" folder in the downloadable .zip file, mainly for training purpose.
- Sample of image upload
- Sample of using Img2thumb.php to resize images
- Sample use of "Cart.php"
|
Site Launch Notes
- All links leading to outside websites will open in a new browser
- All text links will have same look and feel through out the site. It's ok for the footer links to have a lighter color
- Text links should have a distinctive visited color so people can tell which links they have not yet clicked on
- All images used on the site will have alt tags, for human visitors as well as search engines
- Meta tags will be included on all pages, mainly for search engines
- Style sheets will be used to control the look and feel of ALL pages, to ensure consistency
- Page layout needs to be verified on major browser types and platforms
New Circle Blog
For current web technology discussion, reviews and ideas, please check out New Circle Blog.