php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #16738 confusing explanation of assigning by reference
Submitted: 2002-04-22 16:59 UTC Modified: 2002-04-22 18:47 UTC
From: benh at uk2 dot net Assigned: alindeman (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.2.0 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: benh at uk2 dot net
New email:
PHP Version: OS:

 

 [2002-04-22 16:59 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?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-22 17:21 UTC] alindeman@php.net
assigned to myself

 [2002-04-22 18:47 UTC] bs@php.net
This bug has been fixed in CVS.
 [2003-03-07 03:09 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?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 10:01:27 2024 UTC