Re: Container or Calling Class

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

 



Stuart wrote:
2009/5/24 phphelp -- kbk <phphelp@xxxxxxxxxxx>:
If so, can the bar_handler->bar_toast() function call a function in the
container class (foo_handler)? "Parent" is used in some OOP languages for
this type of hierarchy, but not PHP. I have fooled around with the scope
resolution operator, but either that doesn't do it or I can't nail the
syntax.

Anyone care to illuminate this for me?

I've never heard of this being possible in any language, never mind
PHP. The parent keyword you mention refers to the parent class not the
container, and works just as well in PHP as in other languages. Any
OOP implementation that allows a class to call functions in a
container class would be breaking one of the cardinal rules of OOP.

-Stuart


no offence but it smacks a bit of bad design tbh - however one possibility is to inject a reference to the container class instance in to the child

$this->bar_handler = new bar_handler( $this );

--
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