php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46277 implicit reference is not safe to use
Submitted: 2008-10-12 10:26 UTC Modified: 2009-04-06 21:18 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ido at niger dot co dot il Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS, 6CVS (2008-10-22) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ido at niger dot co dot il
New email:
PHP Version: OS:

 

 [2008-10-12 10:26 UTC] ido at niger dot co dot il
Description:
------------
The example prints 9 as the value of $a , though it should be 8;
The fact the referencing $a[0] causes $a[0] to become a reference itself , is dangerous in cases like this where it is possible to change the value of $a[0] though it was not originally defined as a reference.





Reproduce code:
---------------
function a($c){
  $c[0] = 9;
}

$a[0] = 8;

$c = &$a[0];
a($a);
echo $a[0];

Expected result:
----------------
The value of $a should be 8

Actual result:
--------------
The value printed is 9

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 21:18 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://www.php.net/manual/en/language.references.whatdo.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Sep 10 16:00:01 2025 UTC