Hi,
The code below is actually code to access an object's member. That's
fine as long as you give the name of the member at the time you write
the code. What I am interested is to know if the members name might be a
variable, I mean not hardcoded but a variable useful for loops, etc.
Thanks.
Sean C. McCarthy
SCI, S.L. (www.sci-spain.com)
Cerel wrote:
>
> Try this :
>
> class foo {
> var $var1="hello";
> var $var2="world";
> }
> ...
> ...
> $fooinstance = new foo;
> $vartest=$fooinstance->var1;
> echo ($vartest); // should be 'hello'
>
> This should work, but i had no time to test this code.
>
> See you later
>
> Sean C. McCarthy <[EMAIL PROTECTED]> a écrit dans le message :
> [EMAIL PROTECTED]
> > Hi All,
> >
> > I was wondering if it is possible to access dinamically to the members
> > of a class. I mean to access like:
> >
> > ----------------------
> > class foo {
> > var $bar;
> > var $barbar;
> > }
> >
> > ..
> > ..
> >
> > $foo_instance = new foo;
> > $somevar = $foo->$anothervar;
> > -----------------------------
> >
> > I now this doesn't work, and have searched the manual and haven't found
> > anything on it. I doubt it since this is more or less the work of the
> > Arrays and not the way a class should behave. Anyway any ideas? thanks
> > in advance.
> >
> > Sean C. McCarthy
> > SCI, S.L. (www.sci-spain.com)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]