Bug #16738: confusing explanation of assigning by reference

From: Date: Mon, 22 Apr 2002 20:59:24 +0000
Subject: Bug #16738: confusing explanation of assigning by reference
Groups: php.bugs php.doc 
Request: Send a blank email to php-bugs+get-5588@lists.php.net to get a copy of this message
From: benh@uk2.net Operating system: n/a PHP version: 4.2.0 PHP Bug Type: Documentation problem Bug description: confusing explanation of assigning by reference <?php $foo = 'Bob'; // Assign the value 'Bob' to $foo $bar = &$foo; // Reference $foo via $bar. $bar = "My name is $bar"; // Alter $bar... echo $foo; // $foo is altered too. echo $bar; ?> Why do '$bar = "My name is $bar";'? And then do 'echo $foo' *before* you 'echo $bar'? The point you're trying to make is surely expressed better like this: <?php $foo = 'Bob'; // Assign the value 'Bob' to $foo $bar = &$foo; // Reference $foo via $bar. $bar = "Dave"; // Alter $bar... echo $bar; echo $foo; // $foo is altered too. ?> Clearer for the newcomer to programming, ne? -- Edit bug report at http://bugs.php.net/?id=16738&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=16738&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=16738&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=16738&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=16738&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=16738&r=support Expected behavior: http://bugs.php.net/fix.php?id=16738&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=16738&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=16738&r=submittedtwice

« previous php.bugs (#5588) next »