php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26030 array passed by reference is modified but should'nt be
Submitted: 2003-10-29 12:02 UTC Modified: 2003-10-29 19:45 UTC
From: kevin at hatry dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kevin at hatry dot com
New email:
PHP Version: OS:

 

 [2003-10-29 12:02 UTC] kevin at hatry dot com
Description:
------------
When passing a non-existing portion of an array by reference this portion gets created even if the function does not touch the array => it is modified in the calling line.

It works with string indexes as well.

Reproduce code:
---------------
error_reporting(E_ALL);

$tab2 = array( );

function do_nothing ( &$var ) { 
// code here doesnt matter
}

do_nothing($tab2[10]);
var_dump($tab2);



Expected result:
----------------
array(0) {
}


Actual result:
--------------
array(1) {
  [10]=>
  NULL
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-29 14:12 UTC] moriyoshi@php.net
Related to bug #25996

 [2003-10-29 19:45 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 13:01:33 2024 UTC