470,815 Members | 1,326 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Variable name length

I'm working on a new project that I want to get as human readable as
possible, and was wondering what the constraint on variable naming does
PHP have.

Can I have a variable like:

$provider_center_openings_infant_ft

(34 characters if you want to know)

Also any idea if there is a similar limit to MySQL or Postgre field
names.

I've been coding for decades back when I had a limit of 2 characters
for variables on the old Commodore VIC-20, it's kind of hard to get
used to all this room. I've tried to find my answer in TFMs, but
nothing really goes into that metric, I figure you PHP code masters
would know of any (or possible pitfalls) if it bit you once.

Thanks for any insight,
Larry

Oct 19 '05 #1
3 4995
I don't see why not. However, usually, 34 characters is not all that
readbable. Some shorthand can be used for things that ANY programmer would
know (jpg, img, db, eml, tbl, etc.).

The biggest concerning is value length(characters to 255, etc.).

Hope it helps,
Jim

<la***@portcommodore.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm working on a new project that I want to get as human readable as
possible, and was wondering what the constraint on variable naming does
PHP have.

Can I have a variable like:

$provider_center_openings_infant_ft

(34 characters if you want to know)

Also any idea if there is a similar limit to MySQL or Postgre field
names.

I've been coding for decades back when I had a limit of 2 characters
for variables on the old Commodore VIC-20, it's kind of hard to get
used to all this room. I've tried to find my answer in TFMs, but
nothing really goes into that metric, I figure you PHP code masters
would know of any (or possible pitfalls) if it bit you once.

Thanks for any insight,
Larry

Oct 19 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

la***@portcommodore.com wrote:
I'm working on a new project that I want to get as human readable as
possible, and was wondering what the constraint on variable naming does [...] Also any idea if there is a similar limit to MySQL or Postgre field
names.


Congratulations! You have just been awarded with a wonderful RTFM: :-P

http://dev.mysql.com/doc/refman/5.0/en/legal-names.html

http://www.php.net/manual/en/language.variables.php :
"A valid variable name starts with a letter or underscore, followed by *any*
number of letters, numbers, or underscores."

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/
MSN:i_*************************@hotmail.com
ICQ:72800842
Jabber:iv*********@jabber.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDVgJs3jcQ2mg3Pc8RAkZAAJoCP9O6bBkbNs+acaa5+R bWAWzyzwCfTHpz
N4GehK+8r7m5Lsh9oCYGoJ8=
=tKO8
-----END PGP SIGNATURE-----
Oct 19 '05 #3
Didn't find the MySQL one at all; and I didn't see a number in the PHP
reference which I did see, so I missed that too. But "any number of
characters" is intriguing. I did a test and created a test string
variable called:
$supercalafragilisticexpyaladocious_is_a_variable_ name_that_is_quite_atrocious
And added text to it (it worked) then created:
$supercalafragilisticexpyaladocious_is_a_variable_ name_that_is_quite_atrocious_2
and echoed both back, both were unique..

Impressive, but I think probably some sort of abbreviation for such
long identifiers would be necessary for sanity's sake.

That was a sufficient test but I am still tempted to write up a 32k
variable name to see if it will still stand true. ;-)

Thanks for pointing out the obvious that I missed!

Larry

Oct 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by sylvain.loiseau | last post: by
8 posts views Thread by 2L | last post: by
14 posts views Thread by Luiz Antonio Gomes Pican?o | last post: by
23 posts views Thread by Russ Chinoy | last post: by
13 posts views Thread by lak | last post: by
22 posts views Thread by Tristin.Colby | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.