#42810 [Opn->Csd]: Returning References example is unclear
| From: | felipe@php.net | Date: | Mon, 12 Nov 2007 22:55:41 +0000 |
| Subject: | #42810 [Opn->Csd]: Returning References example is unclear | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-205@lists.php.net to get a copy of this message | ||
ID: 42810
Updated by: felipe@php.net
Reported By: aharvey@php.net
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Irrelevant
PHP Version: Irrelevant
-Assigned To:
+Assigned To: felipe
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2007-10-01 06:17:03] aharvey@php.net
Sorry, forgot about the line wrapping. I've put the example up at
<http://www.adamharvey.name/stuff/php-bug-42810.phps>.
------------------------------------------------------------------------
[2007-10-01 06:14:41] aharvey@php.net
Description:
------------
The example for the "Returning References" page
<http://us3.php.net/manual/en/language.references.return.php>
handwaves
the fact that $found_var needs to be set to either a reference or
concrete value within the /* ...code... */ block, which is a potential
source of confusion for newer programmers, judging by the conversation I
just had on ##php. The following may be a clearer and more complete
example for users to demonstrate the concept:
<?php
class C {
public $value = 42;
public function &getValue() {
return $this->value;
}
}
$c = new C;
$myValue = &$c->getValue(); // $myValue is a reference to $c->value,
which is 42.
$c->value = 2;
echo $myValue; // prints the new value of $c->value, ie
2.
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42810&edit=1