NYCPHP Meetup

NYPHP.org

[nycphp-talk] Length of variable names

Ken Robinson kenrbnsn at rbnsn.com
Tue Jul 3 13:13:05 EDT 2007


Quoting Andy Dirnberger <dirn at dirnonline.com>:

> As far as i goes, I've always assumed it was just shorthand for something
> like index or increment.  Nested for loops are often then controlled with j
> and then k.  You can use these with confidence that people will understand
> the meaning.  But if you feel more comfortable using a variable called
> $counter than one called $i, by all means do so.  There are plenty of people
> out there who refuse to use i.

The use of variable names like $i, $j, $k, etc for counters is a hold  
over from early Fortran which declared that only variables starting  
with certain letters could be integers. The first letter was "i". I  
seem to remember that only the letters i, j, l, l, m, n were used for  
integer variables, so the use quickly became a "standard" and it's  
been carried over into other languages through the use of examples  
written by old time programmers.

Ken



More information about the talk mailing list