RE: [PHP] Re: A variable inside a variable?
I ran into the same problems; here is how I solved them. 1. Install MySQL 5 2. Install PHP 5 3. Modify php.ini extensions directive to point to php_mysql.dll (the one that was packaged with php 5) 4. Here is the tricky one make sure mysql is finding the libmysql.dll packaged WITH MYSQL NOT PHP; 5. net stop mysql 6. net start mysql 7. work hard; play hard -Original Message- From: João Cândido de Souza Neto [mailto:[EMAIL PROTECTED] Sent: Monday, June 26, 2006 4:13 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: A variable inside a variable? Please excuse-me. That $ was putted by mistake. I´sorry... <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > You were on the right track, but this isn't going to work.. for a > couple > reasons: > > $var = 1; # this is fine > $var2 = "$var"; # $var2 == 1 at this point echo $$var2; # you're > going to echo $1 > > Putting $var in double quotes makes PHP evaluate it before assigning > it to $var2, so you won't get $var but the value of $var (1). > > If you did use single quotes, you'd get this: > > $var = 1; # this is fine > $var2 = '$var'; # $var2 == '$var' (literal) echo $$var2; # you're > going to echo $$var > > It seems like you might get $var2 evaluate to $var.. then with $$var > have it evaluate to 1, but doesn't look like PHP digs that deeply. > When I ran it, I got NULL back. > > This might be what you were aiming for: > > $var = 1; # this is fine > $var2 = 'var'; # remove the $.. then you can use single or double > quotes echo $$var2; # $var == var, $var == 1, this should output > correctly > > Good lesson in 'gotchas' though. > > -TG > > = = = Original message = = = > > $var=1; > $var2="$var"; > echo $$var2; > > It~ll echo the $var~s value. > > Hope it~ll help you. > > > ___ > Sent by ePrompter, the premier email notification software. > Free download at http://www.ePrompter.com. -- 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] Re: A variable inside a variable?
Please excuse-me. That $ was putted by mistake. I´sorry... <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > You were on the right track, but this isn't going to work.. for a couple > reasons: > > $var = 1; # this is fine > $var2 = "$var"; # $var2 == 1 at this point > echo $$var2; # you're going to echo $1 > > Putting $var in double quotes makes PHP evaluate it before assigning it to > $var2, so you won't get $var but the value of $var (1). > > If you did use single quotes, you'd get this: > > $var = 1; # this is fine > $var2 = '$var'; # $var2 == '$var' (literal) > echo $$var2; # you're going to echo $$var > > It seems like you might get $var2 evaluate to $var.. then with $$var have > it evaluate to 1, but doesn't look like PHP digs that deeply. When I ran > it, I got NULL back. > > This might be what you were aiming for: > > $var = 1; # this is fine > $var2 = 'var'; # remove the $.. then you can use single or double quotes > echo $$var2; # $var == var, $var == 1, this should output correctly > > Good lesson in 'gotchas' though. > > -TG > > = = = Original message = = = > > $var=1; > $var2="$var"; > echo $$var2; > > It~ll echo the $var~s value. > > Hope it~ll help you. > > > ___ > Sent by ePrompter, the premier email notification software. > Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A variable inside a variable?
You were on the right track, but this isn't going to work.. for a couple reasons: $var = 1; # this is fine $var2 = "$var"; # $var2 == 1 at this point echo $$var2; # you're going to echo $1 Putting $var in double quotes makes PHP evaluate it before assigning it to $var2, so you won't get $var but the value of $var (1). If you did use single quotes, you'd get this: $var = 1; # this is fine $var2 = '$var'; # $var2 == '$var' (literal) echo $$var2; # you're going to echo $$var It seems like you might get $var2 evaluate to $var.. then with $$var have it evaluate to 1, but doesn't look like PHP digs that deeply. When I ran it, I got NULL back. This might be what you were aiming for: $var = 1; # this is fine $var2 = 'var'; # remove the $.. then you can use single or double quotes echo $$var2; # $var == var, $var == 1, this should output correctly Good lesson in 'gotchas' though. -TG = = = Original message = = = $var=1; $var2="$var"; echo $$var2; It~ll echo the $var~s value. Hope it~ll help you. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A variable inside a variable?
$var=1; $var2="$var"; echo $$var2; It´ll echo the $var´s value. Hope it´ll help you. "Alex Major" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > Thanks for your help with my other question, heres a new one for you. > > I need to nest a variable, inside another variable. For example: > > $($buildingname)level > > How (if at all) is this possible? > > Thanks. > Alex. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A variable inside a variable?
Alex Major wrote: Thanks for your help with my other question, heres a new one for you. I need to nest a variable, inside another variable. For example: $($buildingname)level How (if at all) is this possible? Thanks. Alex. Why? What are you doing that requires that that cannot be done with associative arrays? As in, what is wrong with: $level[$buildingname] (I'm only guessing at the correct naming scheme) Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php