Re: Behavior of References with Classes

From: Date: Sun, 17 Dec 2000 03:51:12 +0000
Subject: Re: Behavior of References with Classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30703@lists.php.net to get a copy of this message
Woops. I think I figured this out, but I tried to write a script to make sure I understood and (guess what) using references with the "new" operator is new to 4.0.4. ...and guess who only has Windows at home? heh heh O well. Anybody got a system running 4.0.4 that'd be willing to throw this script up there for me for a little ejamacation? I think it might be a good idea to recommend some serious editing for that section of the manual if what I think I've figured out is correct.... Toby Butzon [ criticism spurs improvement ] ----- Original Message ----- From: "Toby Butzon" <TButzon@ImAWebDesigner.com> To: "PHP List" <php-general@lists.php.net> Sent: Saturday, December 16, 2000 9:57 PM Subject: [PHP] Behavior of References with Classes : Somehow, the following lines from the PHP manual : (http://www.php.net/manual/language.references.whatdo.php) seem really : weirdio to me: : : "Note: Unless you use the syntax above, the result of $bar = new fooclass() : will not be the same variable as $this in the constructor, meaning that if : you have used reference to $this in the constructor, you should use : reference assignment, or you get two different objects." : : What I don't understand is this: if references are simply supposed to create : an alias to a variable's content... : : [ For example, the code... : $foo = "you"; : $bar = &$foo; : ...means in memory you have a value "you" that can be accessed/modified with : EITHER $foo or $bar.] : : ...then how does this end up creating multiple objects of the class? : : My apologies if I'm just stupid... it could be the wording that's confusing : me or it could just be that I'm a confused individual to begin with :) : : I'm just looking for some help or maybe general discussion... anything to : help get this straight in my head. :) Thanks all - : : Toby Butzon : [ criticism spurs improvement ] : : : : : -- : PHP General Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net : For additional commands, e-mail: php-general-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : :

« previous php.general (#30703) next »