Re: Object members dynamic access?

From: Date: Thu, 16 Aug 2001 00:32:24 +0000
Subject: Re: Object members dynamic access?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62922@lists.php.net to get a copy of this message
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 <smccarthy@sci-spain.com> a écrit dans le message : 3B7B1195.3BA38850@sci-spain.com... > 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)

« previous php.general (#62922) next »