Usually I like to give my variables descriptive names, but in the shortest
way possible.

However, with regards to $i being the counter, that's a pretty common coding
practice ($i being used to increment, and usually $j being the next variable
(I believe because its after i in the alphabet but if there's an actual
reason beyond that I'd like to know).  It's used because it's short (one
letter) and almost everybody knows what it does.

I also don't think there's ever a time to just use your first and last name
(or at all, for that matter) as variables, unless somehow those were
descriptive of what they hold (doubtful).

There are, however many standards that people use for variable naming.

camelCasing is one of them (first letter of each 'word' in your variable
name is capitalized except for the first), which I like to use.  Other
people prefer the underscore notation, where each word is seperated by an
underscore (ie my_variable_name).

Other things include Instance variables in classes.  Although not so useful
in PHP (and other languages that require you to prefix instance variables
with something [$this->]), some people prefix instance variables with an
underscore, or sometimes 'm_', for member.

Global variables are usually all capital letters with underscores between
words (MY_GLOBAL_VARIABLE).



These are just some standards however, and there is much debate around them.
Some languages also have different standards than other (C# comes to mind
with function names starting with a capital letter, rather than most that
say start with a lower letter).



The best is really to be able to adapt to different projects if you join
midway, and if you start your own, make sure you're consistent.


On 7/3/07, David Krings <[EMAIL PROTECTED]> wrote:

Hi!

Is there any (noticeable) difference between using short variable names
and long ones? I rather use variable names such as $firstnamecounter
than just $i, $john, or $doe (I've seen code where the developer used
almost exclusively his first and last name for just about everything).
I try to give each important variable a name that is descriptive and
unique within my project so that I can name the same thing by the same
name across multiple scripts.

I just wonder if I should get used to a different naming convention now
that my projects get more complex.

David
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php




--
Brian O'Connor
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to