AW: [PHP-DEV] PHP 4.0 Bug #8816: cross subscript object variable access

From: Date: Sat, 20 Jan 2001 14:44:52 +0000
Subject: AW: [PHP-DEV] PHP 4.0 Bug #8816: cross subscript object variable access
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-44632@lists.php.net to get a copy of this message
hi, we had the same problem. the solution is to instanciate the providerclass with $provider = &new ProviderClass(); another solution would be to implement a static function in your subclass that acts as a classfactory: function providerFactory(&$ProviderInstance) { $ProviderInstance->FOO = new SubClass(); } hope that helps. harald. > -----Ursprüngliche Nachricht----- > Von: tenshi@cinter.de [mailto:tenshi@cinter.de] > Gesendet: Samstag, 20. Jänner 2001 04:16 > An: php-dev@lists.php.net > Betreff: [PHP-DEV] PHP 4.0 Bug #8816: cross subscript object variable > access > > > From: tenshi@cinter.de > Operating system: linux > PHP version: 4.0.4 > PHP Bug Type: Class/Object related > Bug description: cross subscript object variable access > > I today found out a strange thing about the PHP4 object/variable > handling that I can not understand. > > My main script first clones a provider class and stores the new > object into $MAINPROV; > > Then it includes two files that give back two elements of the page. > > My provider class has some subclasses. These shall be loaded on > demand with functions like getFooProvider(). Theese functions > test via <pre>is_object($this->FOO)</pre> if the class is already > loaded. If not it includes the file containing the class > definition and spawns <pre>$this->FOO = new foo($this)</pre>. > > Now listen to this: If I use the load-function in the main script > all works fine. But if the class is loaded from one of the > subclasses (into the main provider class object that is a > variable in the main script) it cannot be accessed in the other > subscript, the second element. This causes the foo-class-file to > be reloaded and throws out an error message because the class is > already defined. > > If anybody can help, it would be very very sad if I had to > workaround pre-loading every subclass that can be used on this > page, because I wanted to make it dynamically load the classes. Thanks! > > > -- > Edit Bug report at: http://bugs.php.net/?id=8816&edit=1 > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.dev (#44632) next »