PHP 4.0 Bug #7444 Updated: General reference problems

From: Date: Thu, 29 Mar 2001 16:41:48 +0000
Subject: PHP 4.0 Bug #7444 Updated: General reference problems
Groups: php.dev 
Request: Send a blank email to php-dev+get-50264@lists.php.net to get a copy of this message
ID: 7444 Updated by: sniper Reported By: heathm@effinitylabs.com Old-Status: Duplicate Status: Bogus Bug Type: *General Issues Assigned To: Comments: Previous Comments: --------------------------------------------------------------------------- [2000-10-24 19:37:51] heathm@effinitylabs.com We've been having lots of problems with references (especially storing references to objects in arrays). We beleive we've narrowed a big part of our problems down to the following example. <?php // What's the difference between this... function foo(&$b) { global $c; $c = &$b; // I don't want a COPY of the variable I want a REFERENCE } $a = "Start"; foo($a); $c = "End"; echo $a; // Shouldn't this echo "End" not start? // ... and this ... $a = "Start"; $b = &$a; $c = &$b; $c = "End"; echo $a; // This echoes "End" as is expected // The latter works just fine but the former doesn't. Why not? ?> I posted a similar example on the PHP mailing list only to be told PHP doesn't support C pointers. What a nice piece of advice. Too bad it doesn't apply here. This introduces all kinds of problems especially when using objects and trying to create object container classes. Thanks, Mike Heath EffinityLabs.com --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=7444&edit=2

« previous php.dev (#50264) next »