Hello,
consider following two classes:
class TDynVars
{
var $vars;
function set ($key, $val)
{
$this->vars[$key] = $val;
}
}
class TRequest
{
var $eventData;
function TRequest ()
{
$this->eventData = new TDynVars;
}
}
and two programs, A and B.
program A:
$r1 = new TRequest;
$r1->eventData->vars[0]=1;
$r2 = $r1;
$r2->eventData->vars[0]=2;
print($r1->eventData->vars[0]);
output of program A should be "1" and is "1", it is OK.
program B:
$r1 = new TRequest;
$r1->eventData->set(0,1);
$r2 = $r1;
$r2->eventData->vars[0]=2;
print($r1->eventData->vars[0]);
output of program B should be obviously "1" and is "2", it is NOT OK.
Why $r2 changes data of $r1 if $r2 is $r1's copy by value not reference?
Why this faulty behaviour is dependent on indirect access using member
function use instead of direct acces?
Note: The program B on PHP3.0.8 runs correctly, but not on PHP4.0.4.
Thank you for solving this fundamental problem.
Roland Divin
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]