RE: [PHP] How can I access the value in a variable whos name is in a string
| From: | Jonathan Rosenberg | Date: | Sat, 18 May 2002 17:03:47 +0000 |
| Subject: | RE: [PHP] How can I access the value in a variable whos name is in a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98272@lists.php.net to get a copy of this message | ||
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:henry@teacake.f9.co.uk]
> Sent: Saturday, May 18, 2002 10:30 AM
> To: php-general@lists.php.net
> 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
>
>