NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Coding Standards

Anirudh Zala arzala at gmail.com
Wed Dec 7 23:07:23 EST 2005


I assume we need to create a general purpose coding standard that can be helpful to member of this group and other as well. We can receive comments, suggestion and input of all members who wants to contribute. After reviewing all input, we can prepare nice  looking coding standard and can place somewhere on Nyphp.org. I assume it can be helpful for other programming languages as well.

Hans, any comments?

Thanks,
Anirudh Zala

On Wed, 07 Dec 2005 21:13:17 +0530, Dan Cech <dcech at phpwerx.net> wrote:

> cliff wrote:
>> If anyone isn't familiar with this, it's worth a read:
>>
>> http://www.dagbladet.no/development/phpcodingstandard/
>>
>> Nice PHP Coding Standard Guide. I love the part about no magic #s. I would
>> make it required reading for any new team member.
>>
>> My only issue is preceding a Class property name with m as in
>> $mClassProperty. m makes me think of method. I'd prefer p for property.
>> Thoughts?
>
> I would be very hesitant to recommend this standard.  I do have a
> particular hate for StudlyCaps so it turned me off right there, however
> the fact is that it hasn't been revised since 2003 and is quite out of date.
>
> There are several references to the old-style $HTTP_*_VARS arrays, and
> no mention of using the superglobal arrays, magic quotes, no discussion
> of single vs double quotes, etc.
>
> That said, many of the more general observations about things such as
> commenting code and using a source management system are very useful, I
> don't know what I would do without SVN (or CVS) for any decent sized
> project.
>
> A more esoteric complaint would be that I prefer tabs over spaces,
> because it allows the developer to control the way code is indented (2
> vs 4 vs 8 etc spaces), and avoids the all-too-common situation of the
> indenting being off by 1 space.  That said, tabs should only be used
> before any text on a line, trailing comments or spacing of assignment
> blocks should be indented with spaces to maintain the layout independent
> of tab spacing settings.
>
> WRT <?php ?> tags, I have embraced a practice I first heard of on this
> list, which is to leave out the end ?> tag and instead use a standard
> comments line like:
>
> // end of script
>
> followed by a single newline (unix-style \n of course)
>
> This avoids the situation where the trailing whitespace after the ?> in
> one of your included files sends output to the browser and breaks all
> your header() and cookie() calls.
>
> The final comment I would give is that the authors refer to
> double-quotes as 'magic quotes' throughout the document.  Considering
> the special meaning of this phrase in PHP this is a very poor choice of
> wording.
>
> Dan
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>



-- 
-----------------------------------------------------
Anirudh Zala (Production Manager)
ASPL, http://www.aspl.in
Ph: +91 281 245 1894
arzala at gmail.com
-----------------------------------------------------



More information about the talk mailing list