Re: Refer a class

From: Date: Mon, 26 Jul 2004 16:41:46 +0000
Subject: Re: Refer a class
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-191894@lists.php.net to get a copy of this message
What version of PHP is this, in php 5, all classes are passed by reference by default i beleive. Jason On Sun, 25 Jul 2004 20:00:18 +0200, Michael Ochs <michael.ochs@gmx.net> wrote: > I can call $myclass->module['mymodule']->variable; so I think the class is > instantiate correctly. But the reference doesn't seem to work, cause the > variable I get ist always the same: > > $myclass->nickname = "xyz"; > $class2 = $myclass->loadModule("mysecondclass"); > $myclass->nickname = "abc"; > > Now, when I call $this->main->nickname in $class2, wich actually should call > $myclass, it returns "xyz" instead of "abc"! > > Any idea? > > Thanks, Michael > > "Jason Davidson" <jason.davidson@gmail.com> schrieb im Newsbeitrag > news:6c925ae204072510516d870312@mail.gmail.com... > > > > If there is no error, check the values of all the vars and array > > ellements in your logic for the first method. Make sure its actually > > getting to the point where it instantiates the new object. > > > > Jason > > > > On Sun, 25 Jul 2004 19:36:44 +0200, Michael Ochs <michael.ochs@gmx.net> > wrote: > > > Hi, > > > I try to load some 'modules' into my class. These modules are other > classes. > > > I want to refer the main class to this new module but that doesn't work. > At > > > the moment it looks like this: > > > > > > Mainclass: > > > > > > function loadModule($name) { > > > if(class_exists($name)) { //Class found > > > if(!$this->module[$name]) { > > > $this->module[$name] = new $name(&$this); > > > } > > > return true; > > > } else { > > > return false; > > > } > > > } > > > > > > The mainfunktion of the module: > > > > > > function module_artikelvote(&$parent) { > > > $this->main = &$parent; > > > return true; > > > } > > > > > > I can use $this->main->VARIABLE but the values are old. If I call a > function > > > with $this->main->func_name(); it doesn't work, but there also isn't > > > an > > > error message! > > > > > > What's wrong with these functions? > > > > > > Thanks for help, Michael > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#191894) next »