ID:               25996
 Comment by:       kevin at hatry dot com
 Reported By:      hongnk at hotmail dot com
 Status:           Verified
 Bug Type:         Zend Engine 2 problem
 Operating System: Irrelevant
 PHP Version:      5CVS, 4CVS
 New Comment:

As i didnt find this bug before submitting mine (surely because we
didnt experience it in the same way), i was asked to add a comment here
with my version of the bug so here it is:

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
}


Previous Comments:
------------------------------------------------------------------------

[2003-10-29 14:13:04] [EMAIL PROTECTED]

Related to bug #26030

------------------------------------------------------------------------

[2003-10-26 21:33:23] hongnk at hotmail dot com

Description:
------------
Accessing array with uninitialized index will normally trigger error:

$a=array();
$b=$a['unknown']; => undefined index error

but if I assign by reference:

$b=&$a['unknown'];

then PHP no longer throw error. (The same goes for assigning undefined
property to an object.)

This makes it difficult to debug scripts.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=25996&edit=1

Reply via email to