Re: $$var

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ashim,

These are called Variable Variables. Ideally they should be avoided,
as they introduce unnecessary legibility issues.

This is what it does in a nutshell, it's actually quite simple:

$foo = 'bar';
$bar = 'foobar';
echo $$foo;    //This prints foobar

What it does is, take the value of $foo (which is 'bar') and if a
variable exists by that name, it will go forth and print the value of
$bar; In this case foobar.
On Sun, Mar 6, 2011 at 11:12 PM, Ashim Kapoor <ashimkapoor@xxxxxxxxx> wrote:
> Dear All,
>
> I was reading the php manual for session_register, and I found the following
> line there : -
>
>
> $_SESSION[$var] = $$var;
>
> Why do I need $$ there ? Can someone explain?
>
> Thank you,
> Ashim
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux