On Sun, 2002-02-17 at 11:05, Christian Blichmann wrote:
> Hi there!


>             if (condition) one_statement();
>             if (condition)
>                 one_statement();
>             else
>                 other_statement();
>             if (condition)
>                 one_statement();
>             elseif (condition)         // or use: else if
>                 other_statement();
>             else
>                 anything();

I don't see the benefit of leaving the braces out when there is only
one statement, and there is potential harm: it's fairly easy to get 
hard-to-track errors when you add more statements to the conditional
but forget to add braces (which might as well have been there to
start with):

if (contition)
    $foo = 'bar';
    echo $foo

I've seen it happen. :) Besides, if code block are always braced, it's
one less inconsistency in the code.


One other thing I'd mention is when people go to great lengths to format
columns in their code:

$foo    = 'Foo';
$bar    = 'Bar';
$foobar = 'FooBar';
This is a small example, but despite the fact that it's sort of  
aesthetically pleasing, what happens when you have a long list of 
those and then come back and need to add one which is one character
longer than the rest? You have to update *every* line. Not a code
problem per se, but a tedious mess.

An excellent book on coding practices is 'Code Complete', by Steve C

There is also the Indian Hill style guide--for C, but highly 
transferrable to PHP:


For a whole list of 'em, check out:


Hope this helps,


 Torben Wilson <[EMAIL PROTECTED]>

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

Reply via email to