#42810 [NEW]: Returning References example is unclear

From: Date: Mon, 01 Oct 2007 06:14:41 +0000
Subject: #42810 [NEW]: Returning References example is unclear
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-49@lists.php.net to get a copy of this message
From: aharvey@php.net Operating system: Irrelevant PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: Returning References example is unclear 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 bug report at http://bugs.php.net/?id=42810&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42810&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42810&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42810&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42810&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42810&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42810&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42810&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42810&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42810&r=support Expected behavior: http://bugs.php.net/fix.php?id=42810&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42810&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42810&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42810&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42810&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42810&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42810&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42810&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42810&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42810&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42810&r=mysqlcfg

« previous php.doc.bugs (#49) next »