RE: [PHP] Proper code formatting
| From: | Bob McConnell | Date: | Mon, 23 Mar 2009 12:12:02 +0000 |
| Subject: | RE: [PHP] Proper code formatting | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290564@lists.php.net to get a copy of this message | ||
From: Michael A. Peters
> Angus Mann wrote:
>> Hi all, I'm fairly new to PHP so I don't have too many bad habits
yet.
>>
>> I'm keen to make my code easy to read for me in the future, and for
>> others as well.
>>
>> Are there any rules or advice I can use for formatting (especially
>> indenting) code?
>>
>> for example how best to format / indent this ?
>>
>
> To each his own. Whatever floats your canoe.
> Just whatever you pick, stick to it throughout your code.
>>
>>
>> I'm using "PHP designer 2008" which does syntax coloring but if it
has
>> something to automatically indent - I haven't found it yet.
>
> It probably allows you to either set a specify a tab as a real tab or
a
> specified number of spaces. Auto-indenting - this isn't python, the
> compiler doesn't enforce it's way, you follow the convention of the
> project you are working on - so I suspect many php editors tailored to
> php don't have an auto indent.
>
> I've never of course tried that specific product. I use bluefish, vi,
> and emacs.
To take this question a step further, is there a PHP best practices
document available? I am looking for one that I can give to a new
programmer and tell her "do it this way until you can explain to me why
you shouldn't."
Bob McConnell