473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 5084
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
4
by: sylvain.loiseau | last post by:
Hello Given a node set, I try to compute the total of the string-length value of each node. For instance, with : <xsl:for-each select="//q"> <!-- the length of each node is compute with:...
8
by: 2L | last post by:
Trying to write some code and this is just shitting me now! Bit of form validation stuff.... Variable is declared as follows..... --snip-- <script language="JavaScript"> <!---
14
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
1
by: satish2112 | last post by:
Hi, I have a text-area which contains values from mysql database and 2 buttons, Edit and Update. When I click on the Edit button, I can edit the text-area (initially non-editable). After this,...
13
by: lak | last post by:
I want to know what is the variable length in c. I K&R they stated that atleast 31 character. But I give 1 lakhs length to a variable, but my compiler doesn't say any error. It accepts it.Then...
22
by: Tristin.Colby | last post by:
Can someone tell me why giv_len isn't being seen in this statement below "printf("Record %d wrong length:%d Should be %d \n",record,cur_len,giv_len)" =cut #include <stdio.h> #include...
1
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.