If I pass a reference to an object and assign that to a class property.
Shouldn't the property be a reference back to the original variable's value
instead of a copy?

Here is some sample code to illustrate my small confusion.


class Testie
  var $error;

  function Testie()

class Tester
  var $testie;

  function Tester(&$testie) // <-- passing object by reference
      $this->testie = $testie; // <--- I must put an & again if I want this
to be a reference even though
                                      //        I already passed a reference

$t = new Testie();

$a = new Tester(&$t);

$a->testie->error = "Hello 123";

$t->error = "GoodBye 123";

print "A::error ".$a->testie->error."\n";
print "T::error $t->error\n";


// with the &
A::error GoodBye 123
T::error GoodBye 123

// Without the &
A::error Hello 123
T::error GoodBye 123

I suppose this is intended behavior and my laziness is getting the better of

Chris Newbill
OneWest.net Inc.,


Windows crashed.
I am the Blue Screen of Death.
No one hears your screams.

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]

Reply via email to