Bug #16738 Updated: confusing explanation of assigning by reference
| From: | bs@php.net | Date: | Mon, 22 Apr 2002 22:47:43 +0000 |
| Subject: | Bug #16738 Updated: confusing explanation of assigning by reference | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-5596@lists.php.net to get a copy of this message | ||
ID: 16738
Updated by: bs@php.net
Reported By: benh@uk2.net
-Status: Assigned
+Status: Closed
Bug Type: Documentation problem
Operating System: n/a
PHP Version: 4.2.0
Assigned To: alindeman
New Comment:
This bug has been fixed in CVS.
Previous Comments:
------------------------------------------------------------------------
[2002-04-22 17:21:41] alindeman@php.net
assigned to myself
------------------------------------------------------------------------
[2002-04-22 16:59:24] benh@uk2.net
<?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 this bug report at http://bugs.php.net/?id=16738&edit=1