SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict CandyMann_69's Avatar
    Join Date
    Jun 2003
    Location
    Phoenix, AZ
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $object -> 1 -> value, why does not work?

    I noticed that you can not use a number for an object holder. You can use a variable with a number in it as an object holder.

    So this will work:
    $key = 1;
    $object -> $key -> value = 'test';

    This will not work:
    $object -> 1 -> value = 'test';

    I was just wondering is someone had some better understanding and could explain to me why this is? Is this more like a bug? Something that is going to be added later? Something that should not be done?

    Thanks!

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    São Paulo, Brasil
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Variables and object members can't start with numbers, this is a rule since ancient times
    Ricardo "Solo" Hermida Ruiz
    solo (a) hardmob.com.br
    twlimcsb cassmmvi

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    New Jersey
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Variable names cannot begin with a number. Thus, $this->variable will work, but $this->3rdvariable will not.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •