Just some advice... You should use a consistent programming style, 
especially with PHP. You can read some guys advice here. 

Some of the advantages of having a consistent style, is when you are 
looking for bugs. If you look over your code and see something unusual, 
then you can target that area to see if it is the culprit. If you don't 
have a consistent style, then sometimes that can cause serious 
heartache, as everything will look unusual.

A few issues that trip up most people when beginning to use PHP, is the 
syntax errors. Usually these arise from quote issues, to semi-colon and 
brace issues. A lot of this trouble can be avoided (or easily debugged) 
by simply using tabs to your advantage. Consider the following:

<?php if ($condition){ echo "correct";} else {
echo 'what';
if (!$condition2){
include 'thing.php';
while (!$dead)
{ if ($jam!= $yes){ $dead = true;
} else{
for ($i=0;$i<100;$i++)
{ $thing = processSomething('something', "something2");
$string = 'something'.$here."too";

Technically I *think* this would be syntactically correct, but if I was 
looking for a bug, I would be shot in the foot. A better way to write 
this would be the following:


if ($condition){
        echo "correct";
} else {
        echo "what";
        if (!$condition2){
                include ('thing.php');
                while (!$dead){
                        if ($jam != $yes){
                                $dead = true;
                        } else {
                                for ($i=0;$i<100;$i++){
                                        $thing = processSomething("something", 
                                        $string = "something $here too";


So its a couple more lines, but if I came back to that script a month or 
two months later trying to fix something, or add a new feature, it would 
be easy. Couple that style with comments and you're on fire!!!

Hope this helps for someone out there...


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to