PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #16738 confusing explanation of assigning by reference
Submitted:22 Apr 2002 4:59pm UTC Modified: 22 Apr 2002 6:47pm UTC
From:benh at uk2 dot net Assigned to:alindeman
Status:Closed Category:Documentation problem
Version:4.2.0 OS:n/a
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN account, you can't do anything here. You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: benh at uk2 dot net
New email:
Version: OS:
New/Additional Comment:

[22 Apr 2002 4:59pm UTC] benh at uk2 dot 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?
[22 Apr 2002 5:21pm UTC] alindeman@php.net
assigned to myself
[22 Apr 2002 6:47pm UTC] bs@php.net
This bug has been fixed in CVS.
[7 Mar 2003 3:09am UTC] jharders at tricept dot de
I've downloaded the latest PHP5-win-binary-package,
assuming that bug will would fixed, but it is'nt?

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC