+ Post New Thread
Results 1 to 7 of 7
Jokes/Interweb Things Thread, PHP variable variables in Fun Stuff; PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". ...
  1. #1
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112

    PHP variable variables

    PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable. And this is why I don't use PHP

    PHP: Variable variables - Manual
    Last edited by somabc; 18th October 2010 at 05:31 PM.

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,422
    Thank Post
    645
    Thanked 967 Times in 667 Posts
    Blog Entries
    2
    Rep Power
    328
    Nothing wrong with PHP if used correctly.

  3. #3

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242
    Quote Originally Posted by somabc View Post
    And this is why I don't use PHP
    I'd rather the language I use have a feature that is not necessary to me, than not having a feature that is.

  4. #4

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    18,529
    Thank Post
    527
    Thanked 2,648 Times in 2,049 Posts
    Blog Entries
    24
    Rep Power
    925
    I've needed that functionality in the past. Glad PHP has it!

  5. #5
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112
    It is fun.

    Code:
      //You can even add more Dollar Signs
    
      $Bar = "a";
      $Foo = "Bar";
      $World = "Foo";
      $Hello = "World";
      $a = "Hello";
    
      $a; //Returns Hello
      $$a; //Returns World
      $$$a; //Returns Foo
      $$$$a; //Returns Bar
      $$$$$a; //Returns a
    
      $$$$$$a; //Returns Hello
      $$$$$$$a; //Returns World
    
      //... and so on ...//

  6. #6

    sonofsanta's Avatar
    Join Date
    Dec 2009
    Location
    Lincolnshire, UK
    Posts
    5,375
    Thank Post
    958
    Thanked 1,630 Times in 1,103 Posts
    Blog Entries
    47
    Rep Power
    711
    Things like that are the reason I love PHP so much for development; it's so damn flexible with its variables (I <3 no types) that you never end up digging through the manual to find the correct form for a datatype, or the function to typecast, you just get on with it. There's probably six different ways you could think of to do most things and PHP will probably let you code them all first time without too much hassle.

    .Net, on the other hand... great for the 5% of projects that are real quick 'n' dirty, great for the 5% at the other end where you build your library up, but for the other 90% in the middle it never had the flexibility of PHP for me.

  7. #7
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112



SHARE:
+ Post New Thread

Similar Threads

  1. Pass a program variable in VB Script?
    By cookie_monster in forum Coding
    Replies: 21
    Last Post: 22nd April 2013, 09:04 AM
  2. [ASP.net] Must declare the scalar variable "@Name".
    By damienharrison in forum Web Development
    Replies: 3
    Last Post: 30th May 2010, 08:02 PM
  3. Environment Variable for a users full name.
    By Stuart_C in forum Windows
    Replies: 3
    Last Post: 16th May 2010, 12:42 PM
  4. Moodle - undefined variable error
    By damienharrison in forum Virtual Learning Platforms
    Replies: 5
    Last Post: 26th September 2007, 11:15 AM
  5. %Userprofile% Variable not being set.
    By drjturner in forum Windows
    Replies: 16
    Last Post: 23rd November 2006, 10:07 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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