Doc #60059 [NEW]: Passing by Reference also accepts array elements

From: Date: Thu, 13 Oct 2011 23:09:13 +0000
Subject: Doc #60059 [NEW]: Passing by Reference also accepts array elements
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7323@lists.php.net to get a copy of this message
From: Operating system: PHP version: Irrelevant Package: Documentation problem Bug Type: Documentation Problem Bug description:Passing by Reference also accepts array elements Description: ------------ According to http://ca.php.net/manual/en/language.references.pass.php : The following things can be passed by reference: Variables, i.e. foo($a) New statements, i.e. foo(new foobar()) References returned from functions, i.e.: [...] No other expressions should be passed by reference, as the result is undefined. This appears to be inexact. Elements of array variables can apparently also be passed by reference, unless this works by chance. Test script: --------------- <?php function two(&$int) { $int = 2; } $a = array(1); two($a[0]); var_dump($a); Actual result: -------------- array(1) { [0]=> int(2) } -- Edit bug report at https://bugs.php.net/bug.php?id=60059&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60059&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60059&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60059&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60059&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60059&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60059&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60059&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60059&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60059&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60059&r=support Expected behavior: https://bugs.php.net/fix.php?id=60059&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60059&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60059&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60059&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60059&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60059&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60059&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60059&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60059&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60059&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60059&r=mysqlcfg

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