Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    php
  » Variable Varaibles
      by falsepride
 Page 1 of 1 
   

(Login to remove green text ads)
Okay heres something that can come inhandy of be totally useless to you depending on how you do things. I, myslef have used this before. Variable variables are a variable where the variables name is a variable ex.

PHP Code:
<?php

$name 
"test";
$test "hello world";
echo $
$name;

?>
The above would print out hello world.
It prints out hello world instead of test because your using a variable variable. Lets look at this an easier way. The last line,
PHP Code:
echo $$name
can look confusing but if we add {} it looks a little cleaner.
PHP Code:
echo ${$name}; 
If people still dont understand variable variables if you were to break down the last line step by step, it would be:
PHP Code:
1. echo ${$name};
2. echo ${test};
3. echo $test





 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle