"Greg" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I was just trying this but it doesn't work :
>
> class a {
>public $foo = "hello world";
> }
>
> $obj = new a();
> $varname = "foo";
> echo $obj->$$varname;
>
$$varname is turned into $foo, what is the value of $foo?
If you're trying to access "public $foo" then Richard was entirely correct
(sorry richard!), just do it like so: $a->foo
If, like in the below example, $foo is the name of a variable that you want
to access, then try ${$foo}, everynow and then there's a problem to that
effect
Good luck, welcome to oop :)
> $bar = "this is working";
> $varname = "bar";
> echo $$varname; // display "this is working" as expected
> ?>
>
> Is it a bug or is it normal ?
> I didn't find anything about it in documentation (php4 / php5).
>
> Greg
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php