RE: [PHP-DEV] Class related mayhem...
| From: | John Parker | Date: | Mon, 06 Nov 2000 12:23:11 +0000 |
| Subject: | RE: [PHP-DEV] Class related mayhem... | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37257@lists.php.net to get a copy of this message | ||
> ...
>
> JP>> Class userClass
> JP>> {
> JP>> var $userData;
> JP>> var $output;
> JP>>
> JP>> Function userClass()
> JP>> {
> JP>> $this->output = new outputUserClass;
> JP>> }
> JP>> }
> JP>>
> JP>>
> JP>> In this example, is it possible for the outputUserClass to access the
> JP>> userData variable with userClass?
>
> Since PHP places no restriction on class member access, any code can
> access any member of any class.
>
> But, if you are asking _how_ to access this, then probably you should make
> outputUserClass object somehow to know it's containing object.
>
Yup, I'm asking 'how'. (Sorry.)
I've attempted to pass a reference into the outputUserClass, as in:
$this->output = new outputUserClass($this->userData);
But this doesn't seem to work. (ie: outputUserClass seems unable to access
anything in userData (which is an array, incidentally).)
Any ideas?
JP.