object referencing problem

From: Date: Wed, 03 Apr 2002 15:57:33 +0000
Subject: object referencing problem
Groups: php.lang 
Request: Send a blank email to php-lang+get-284@lists.php.net to get a copy of this message
hi, I have a problem..... I have a modular framework application where I use class constructor to load proper modules ( classes ). First class calls second class constructor and gives it's own $this as a parameter. class a { var $_mods = array(); function a(){ new b( &$this ); } } Second class calls bunch of modules, assignes them to a class a's member $_mods and gives those modules $that ( a::this ) as a parameter. Don't ask me why, too complex to explain :) class b { function b( &$that ){ // <-- a::this $that->_mods["mod1"] = new mod1(&$that); $that->_mods["mod2"] = new mod2(&$that); } } Today I found that this kind of approach somehow results 2 php prosecces to execute same code at the same time in one http-request . I did some mail sending and got very confused when mail got doubbled even when I added die("aaaargh") right after mail() function call. I logged timestamps and pids into file and found out that there were 2 entries with one click with different pids. I know, this kind of code will most propably misbehave and act unpredictable in many ways. Any ideas what makes process to be duplicated ? Teemu php 4.0.2 / 4.1.2 Apache 1.3.12 OS: Solaris something

« previous php.lang (#284) next »