Re: [PHP] Purpose of $$var ?????
Alright! Found the problem! Faulty script written that come before this script where $$var come into play. At least, it wasn't me, it was the other programmer's error. :-) "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Interesting! Look like the 2nd "$" is decomissioned and is reserve for > something in the future or something. Just like the "_" is when it come > with $_POST as an example. That would explain why it doesn't work with PHP > 4.2.x & up. > > "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message > 002601c22cd0$b1995170$1601a8c0@nik">news:002601c22cd0$b1995170$1601a8c0@nik... > > Variable variable. Read the docs. > > > > $v = 'foo'; > > $foo = 'bar'; > > echo $$v; > > > > Regards, > > Andrey > > > > P.S. > > Sometimes {} are used : ${$v} > > > > > > > > > > "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message > > news:<[EMAIL PROTECTED]>... > > > The script was working great before PHP 4.2.x and not after that. So, I > > > looked through the code and came upon this variable, "$$var". I have no > > > idea what the purpose of the double "$" is for a variable. Anyone know? > > > > > > --clip-- > > > $var = "v".$counter."_high_indiv"; > > > $val3 = $$var; > > > --clip > > > > > > Thanks, > > > FletchSOD > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Purpose of $$var ?????
What docs at php.net? under variable, predefine variable or what? "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message 002601c22cd0$b1995170$1601a8c0@nik">news:002601c22cd0$b1995170$1601a8c0@nik... > Variable variable. Read the docs. > > $v = 'foo'; > $foo = 'bar'; > echo $$v; > > Regards, > Andrey > > P.S. > Sometimes {} are used : ${$v} > > > > > "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... > > The script was working great before PHP 4.2.x and not after that. So, I > > looked through the code and came upon this variable, "$$var". I have no > > idea what the purpose of the double "$" is for a variable. Anyone know? > > > > --clip-- > > $var = "v".$counter."_high_indiv"; > > $val3 = $$var; > > --clip > > > > Thanks, > > FletchSOD > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Purpose of $$var ?????
I tried that test script you mentioned and it doesn't work in PHP 4.2.1. I have a very good idea why is that, must have to do with the php.ini. Unfortunately, it doesn't work either. I'll tell you what, I'll just throw out that script and write a different script. This time, no double "$". --clip-- for($i=1;$i<100;$i++){ $user="user".$i; echo $$user."*"; } --clip-- "Joakim Andersson" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > The cause for your problem would be that register_globals defaults to off in > PHP 4.2.x and greater. > The solution? Start using the new superglobals ($_POST, $_GET, $_SESSION > etc) or (not recomended) set register_globals = on in php.ini > > Read more here: > http://www.php.net/manual/en/language.variables.predefined.php > > Regards > Joakim Andersson > > > > -Original Message- > > From: Scott Fletcher [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, July 16, 2002 3:54 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] Purpose of $$var ? > > > > > > The script was working great before PHP 4.2.x and not after > > that. So, I > > looked through the code and came upon this variable, "$$var". > > I have no > > idea what the purpose of the double "$" is for a variable. > > Anyone know? > > > > --clip-- > > $var = "v".$counter."_high_indiv"; > > $val3 = $$var; > > --clip > > > > Thanks, > > FletchSOD > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Purpose of $$var ?????
variable variable... right up there with array array basically what you are saying is resolve $var, then find out what that variable holds example; assume your $counter is currently at 5 $var = "v".$counter."_high_indiv"; would mean that $var= "v5_high_indiv" assuming that v5_high_indiv is dynamically assigned somewhere as a variable $$var is the value of $v5_high_indiv make sense? variable variables are especially good in loops... for example, if you have variables called $user1, $user2, $user3 to print out all the variables would require one line per variable (and alot of typing). using variable variables you could print out the value of all users by looping it for($i=1;$i<100;$i++){ $user="user".$i; echo $$user; } Dave >-Original Message- >From: Scott Fletcher [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, July 16, 2002 9:54 AM >To: [EMAIL PROTECTED] >Subject: [PHP] Purpose of $$var ? > > >The script was working great before PHP 4.2.x and not after that. So, I >looked through the code and came upon this variable, "$$var". I have no >idea what the purpose of the double "$" is for a variable. Anyone know? > >--clip-- >$var = "v".$counter."_high_indiv"; >$val3 = $$var; >--clip > >Thanks, > FletchSOD > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Purpose of $$var ?????
The cause for your problem would be that register_globals defaults to off in PHP 4.2.x and greater. The solution? Start using the new superglobals ($_POST, $_GET, $_SESSION etc) or (not recomended) set register_globals = on in php.ini Read more here: http://www.php.net/manual/en/language.variables.predefined.php Regards Joakim Andersson > -Original Message- > From: Scott Fletcher [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 16, 2002 3:54 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Purpose of $$var ? > > > The script was working great before PHP 4.2.x and not after > that. So, I > looked through the code and came upon this variable, "$$var". > I have no > idea what the purpose of the double "$" is for a variable. > Anyone know? > > --clip-- > $var = "v".$counter."_high_indiv"; > $val3 = $$var; > --clip > > Thanks, > FletchSOD > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Purpose of $$var ?????
Interesting! Look like the 2nd "$" is decomissioned and is reserve for something in the future or something. Just like the "_" is when it come with $_POST as an example. That would explain why it doesn't work with PHP 4.2.x & up. "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message 002601c22cd0$b1995170$1601a8c0@nik">news:002601c22cd0$b1995170$1601a8c0@nik... > Variable variable. Read the docs. > > $v = 'foo'; > $foo = 'bar'; > echo $$v; > > Regards, > Andrey > > P.S. > Sometimes {} are used : ${$v} > > > > > "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... > > The script was working great before PHP 4.2.x and not after that. So, I > > looked through the code and came upon this variable, "$$var". I have no > > idea what the purpose of the double "$" is for a variable. Anyone know? > > > > --clip-- > > $var = "v".$counter."_high_indiv"; > > $val3 = $$var; > > --clip > > > > Thanks, > > FletchSOD > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Purpose of $$var ?????
Variable variable. Read the docs. $v = 'foo'; $foo = 'bar'; echo $$v; Regards, Andrey P.S. Sometimes {} are used : ${$v} "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > The script was working great before PHP 4.2.x and not after that. So, I > looked through the code and came upon this variable, "$$var". I have no > idea what the purpose of the double "$" is for a variable. Anyone know? > > --clip-- > $var = "v".$counter."_high_indiv"; > $val3 = $$var; > --clip > > Thanks, > FletchSOD > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Purpose of $$var ?????
The script was working great before PHP 4.2.x and not after that. So, I looked through the code and came upon this variable, "$$var". I have no idea what the purpose of the double "$" is for a variable. Anyone know? --clip-- $var = "v".$counter."_high_indiv"; $val3 = $$var; --clip Thanks, FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php