:: Personal website of a Toronto web designer
Lately » PHP coding guidelines
Good scripts and programs may still look ugly. Code you write may look nice to you, but terrible to somebody else. I always liked the idea of programming guidelines, but noticed that not so many developers and programmers stick to them.
There is an article at Evolt.org worth reading, PHP coding guidelines. I pretty much agree with everything said there, except of the tabs vs. space issue maybe.
PHP Tip: Not much known but very useful for debugging purposes are two functions, print_r() and var_dump(). They are both similar in their behavior, print_r() will print the contents of any variable, array or object. var_dump() will additionally print out the data types for each element in an array or object.
:: Sasha, at 08:22 pm on Monday, 05. January 2004
I like your "Tip" section very much. ;-)
:: Davor, at 08:00 am on Tuesday, 06. January 2004
Thx. I realized, I am much better in writting small tips now and then, than writting an article. With the time, I'll create a section with all tips on one place.
:: Sasha, at 10:25 am on Tuesday, 06. January 2004
well, I guess if you've thought about style enough to disagree with some of his points, you're on firm ground in my book.
He can't seriously say that the One True Brace Style is incorrect, though, can he?
/me boggles
:: linear, at 11:35 pm on Tuesday, 06. January 2004
He says, "in my opinion" knowing that many will disagree with his brace style. I like Allman Style, as explained at http://www.wkonline.com/d/indent_style.html simply because our professor thought us so :-)
I guess, it is OK to use any style as long as I stick to it through my program. It would be great to have some standards though.
Nice house by the way!
:: Sasha, at 11:59 pm on Tuesday, 06. January 2004
I agree with most of what the author said. In fact, I prefer tabs to spaces.
Also, I always write code with BSD/Allman style braces.
see here: http://www.kafejo.com/komp/1tbs.htm
:: Steve, at 12:04 am on Wednesday, 07. January 2004
I agree with the Tabs vs. Spaces issue. Tabs should always be used because it's so easy to convert them to spaces if need be.
I don't agree with the brace placement however. I used to do it that way and thought it was the right way, but one day I took a chance and changed my way, and it's been worth it.
I place the opening brace after the function or statement declaration, with the closing brace lined up with the left edge of that line on its own line. Makes editing much easier, and takes up less space.. try it, you'll like it too.
:: Ted Wood, at 05:37 pm on Sunday, 11. January 2004
K&R/Kernel style.
I don't know why this style would be seen as bad. I used the BSD style for a year thinking it was the most efficient, but boy was I wrong. My coding efficiency increased when I switched to K&R.
:: Ted Wood, at 05:40 pm on Sunday, 11. January 2004
Useless scrawling facts:
Top 5 scrawlers:
(updated once a day)
556 Sasha
488 zoka
316 vitez-koja
235 Davor
58 mungos

