Re: Container or Calling Class
| From: | Nathan Rixham | Date: | Sun, 24 May 2009 19:58:56 +0000 |
| Subject: | Re: Container or Calling Class | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-293076@lists.php.net to get a copy of this message | ||
Stuart wrote:
2009/5/24 phphelp -- kbk <phphelp@comcast.net>: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 );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