+ 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
    111

    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 04:31 PM.

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    639
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324
    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
    241
    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
    17,680
    Thank Post
    516
    Thanked 2,451 Times in 1,897 Posts
    Blog Entries
    24
    Rep Power
    832
    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
    111
    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
    4,952
    Thank Post
    862
    Thanked 1,443 Times in 991 Posts
    Blog Entries
    47
    Rep Power
    616
    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
    111

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, 08:04 AM
  2. [ASP.net] Must declare the scalar variable "@Name".
    By damienharrison in forum Web Development
    Replies: 3
    Last Post: 30th May 2010, 07:02 PM
  3. Environment Variable for a users full name.
    By Stuart_C in forum Windows
    Replies: 3
    Last Post: 16th May 2010, 11:42 AM
  4. Moodle - undefined variable error
    By damienharrison in forum Virtual Learning Platforms
    Replies: 5
    Last Post: 26th September 2007, 10:15 AM
  5. %Userprofile% Variable not being set.
    By drjturner in forum Windows
    Replies: 16
    Last Post: 23rd November 2006, 09: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
  •