Variable name length

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • larry@portcommodore.com

    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_cente r_openings_infa nt_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

  • James Blews

    #2
    Re: Variable name length

    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(characte rs to 255, etc.).

    Hope it helps,
    Jim

    <larry@portcomm odore.com> wrote in message
    news:1129690133 .793101.150320@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > 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_cente r_openings_infa nt_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
    >[/color]


    Comment

    • Iván Sánchez Ortega

      #3
      Re: Variable name length

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      larry@portcommo dore.com wrote:
      [color=blue]
      > 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[/color]
      [...][color=blue]
      > Also any idea if there is a similar limit to MySQL or Postgre field
      > names.[/color]

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



      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


      MSN:i_eat_s_p_a _m_for_breakfas t@hotmail.com
      ICQ:72800842
      Jabber:ivansanc hez@jabber.org
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.2 (GNU/Linux)

      iD8DBQFDVgJs3jc Q2mg3Pc8RAkZAAJ oCP9O6bBkbNs+ac aa5+RbWAWzyzwCf THpz
      N4GehK+8r7m5Lsh 9oCYGoJ8=
      =tKO8
      -----END PGP SIGNATURE-----

      Comment

      • larry@portcommodore.com

        #4
        Re: Variable name length

        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:
        $supercalafragi listicexpyalado cious_is_a_vari able_name_that_ is_quite_atroci ous
        And added text to it (it worked) then created:
        $supercalafragi listicexpyalado cious_is_a_vari able_name_that_ is_quite_atroci ous_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

        Comment

        Working...