[PHP] How can I access the value in a variable whos name is in a string

2002-05-18 Thread Henry

Dear All,

$variablename=variable;
eval(\$.$variablename.=13;);
echo $variable;

This works fine!! It echoes 13;

But this doesn't -

echo eval(\$variablename\);

Why??


Henry




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




Re: [PHP] How can I access the value in a variable whos name is in a string

2002-05-18 Thread The_RadiX

simple..


try this:
echo eval($variablename);

then again why are you eval()ing at all??


why can't you do this:

$var1=var2;
$$var1=13;
echo $var2;

//or perhaps even better:
//echo $$var1;

seems simple enough.. haven't tested but theory is there I think..

HTH

:::
:  Julien Bonastre [The-Spectrum.org CEO]
:  A.K.A. The_RadiX
:  [EMAIL PROTECTED]
:  ABN: 64 235 749 494
:  QUT Student #: 04475739
:::
- Original Message -
From: Henry [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, May 19, 2002 12:29 AM
Subject: [PHP] How can I access the value in a variable whos name is in a
string


 Dear All,

 $variablename=variable;
 eval(\$.$variablename.=13;);
 echo $variable;

 This works fine!! It echoes 13;

 But this doesn't -

 echo eval(\$variablename\);

 Why??


 Henry




 --
 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] How can I access the value in a variable whos name is in a string

2002-05-18 Thread Jonathan Rosenberg

I'm a PHP amateur, but a quick perusal of Eval in the manual says

In PHP 4, eval() returns FALSE unless return() is
called in the evaluated code, in which case the
value passed to return() is returned. In PHP 3,
eval() does not return a value.

 -Original Message-
 From: Henry [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, May 18, 2002 10:30 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] How can I access the value in a 
 variable whos name is in
 a string
 
 
 Dear All,
 
 $variablename=variable;
 eval(\$.$variablename.=13;);
 echo $variable;
 
 This works fine!! It echoes 13;
 
 But this doesn't -
 
 echo eval(\$variablename\);
 
 Why??
 
 
 Henry
 
 
 
 
 -- 
 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