php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38607 References in function
Submitted: 2006-08-26 10:21 UTC Modified: 2006-08-26 10:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kilgor at twojepc dot pl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.5 OS: Windows/Linux
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: kilgor at twojepc dot pl
New email:
PHP Version: OS:

 

 [2006-08-26 10:21 UTC] kilgor at twojepc dot pl
Description:
------------
PHP 5.1.1 is the last version of PHP which gave expected result of this statement. I noticed that next versions return wrong result.

I tested PHP version 5.1.2, 5.1.4, 5.1.6 and the all returned unexpected (wrong) result.

As you can see, the mistake appeares when you assign value to the variable which is passed to function as a reference:

In my example: test($i=array());


Reproduce code:
---------------
<?

function test(&$x)
{
	$x[]=1;
	$x[]=2;
	$x[]=3;
}

test($i=array());
$i[]=4;

var_dump($i);

?>

Expected result:
----------------
array(4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(4)
}

Actual result:
--------------
array(1) {
  [3]=>
  int(4)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-26 10:50 UTC] derick@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

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 11:01:33 2025 UTC