note 6807 deleted from Function arguments by ronabop

From: Date: Fri, 24 Nov 2000 06:31:01 +0000
Subject: note 6807 deleted from Function arguments by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-8072@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> class Test {<br> var $testVar;<br> <br> function Test() { $testVar = ""; }<br> function setTestVar( &$ref) {<br> $this->testVar = $ref; }<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 (#8072) next »