note 6808 deleted from Classes and Objects by ronabop

From: Date: Thu, 17 Aug 2000 10:01:39 +0000
Subject: note 6808 deleted from Classes and Objects by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-2169@lists.php.net to get a copy of this message
why does'nt passing arguments by reference work within a class? this is a serious thing because it means, that all objects passed as paramter to other objects are copied every time. the following example should output blubblah, but the output is only blub:<br><br> class Test {<br> var $testVar;<br> <br> function Test() { $testVar = ""; }<br> <br> function setTestVar( &$ref) {$this-testVar = $ref; }<br> <br> function getTestVar() { return $this-testVar; }<br> }<br> <br> $testObject = new Test();<br> $testVar = "blub";<br> $testObject-setTestVar( $testVar);<br> $testVar .= "blah";<br> print $testObject-getTestVar();<br>

« previous php.notes (#2169) next »