note 6945 modified in language.oop by irc-html

From: Date: Sat, 19 Jan 2002 19:40:36 +0000
Subject: note 6945 modified in language.oop by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25268@lists.php.net to get a copy of this message
"Why passing arguments by reference doesn't work within a class": The problem lies not with the referenced argument but with the testVar member of the Test class. This variable is NOT a reference so when you assign the parameter to it, it copies the string to it. from a test i did .. you should simply change the setTestVar() function to this: $this-testVar = &$ref; NOTE: i'm pretty new to the PHP world and can't certify that what i say is right but it is my assumption based on my experience with other programming languages. --was-- "Why passing arguments by reference doesn't work within a class": The problem lies not with the referenced argument but with the testVar member of the Test class. This variable is NOT a reference so when you assign the parameter to it, it copies the string to it. from a test i did .. you should simply change the setTestVar() function to this: <PRE>$this-testVar = &$ref;</PRE> NOTE: i'm pretty new to the PHP world and can't certify that what i say is right but it is my assumption based on my experience with other programming languages. http://www.php.net/manual/en/language.oop.php

« previous php.notes (#25268) next »