Re: Scope woe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think the best way is passing the object instance as a parameter to the 
messwithotherthings method.

-- 
João Cândido de Souza Neto
SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
Fone: (0XX41) 3033-3636 - JS
www.siens.com.br

"Luke" <luke@xxxxxxxxxxxxxx> escreveu na mensagem 
news:17aa29670906300114t5b95c12dk9dfdfbdfdd7f0a18@xxxxxxxxxxxxxxxxx
> Hello again guys,
>
> I was wondering the best way to tackle the following problem:
>
> I've got a class, containing a property which is another object. So from
> outside I should be able to do
> $firstobject->propertycontainingobject->methodinsidethatobject();
>
> The $firstobject variable is in the global namespace (having been made 
> with
> $firstobject = new FirstObject;), and I'm having a problem that I'm sure
> many people have when accessing it inside another class, so:
>
> class otherObject
> {
> static function messwithotherthings ()
> {
> $firstobject->propertycontainingobject->methodinsidethatobject();
> }
> }
>
> But $firstobject is blank, which makes sense because in there it is 
> pointing
> to the local variable within the method.
>
> To solve this, I could add 'global $firstobject' inside every method, but
> this is very redundant and boring. I've tried a couple of things like
> adding:
>
> private $firstobject = $GLOBALS['firstobject'];
>
> But apparently that's bad syntax. I was just wondering the best way to get
> around this?
>
> Thanks a lot for your help,
>
> -- 
> Luke Slater
> :O)
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux