ID:               27395
 User updated by:  jamesn at tocquigny dot com
 Reported By:      jamesn at tocquigny dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: redhat linux
 PHP Version:      4.3.4
 New Comment:

in response to papercrane, no i didn't mean 

function theFunction(&$array)



(this would pass by reference...by default php is doing this)



By flagging my bug as bogus are you stating the proper behavior is to
always pass by reference?  (Which isn't proper at all IMO nor that of
coworkers or anyone that's worked w/ c/c++)


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

[2004-02-25 12:41:15] [EMAIL PROTECTED]

It works exactly how it's supposed to work.



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

[2004-02-25 12:36:13] papercrane at reversefold dot com

I think you meant:



function theFunction(&$array)



Even with the & it still won't work for me.

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

[2004-02-25 12:02:02] jamesn at tocquigny dot com

Description:
------------
There appears to be a problem with php that doesn't allow arrays to be
passed by value.  The fix appears to be something similar to:
http://bugs.php.net/bug.php?id=6417

if (PZVAL_IS_REF(*p))

{

   SEPARATE_ZVAL(p);

} else {

   zval_add_ref(p);

}



It would appear that that logic is missing in one place or another.  I
could not track it down myself.  Code similar to this appears to be
copy/pasted in various places.

Reproduce code:
---------------
$array = array(1);



// This line makes the call to theFunction() act as if passed by ref.?

$reference =& $array[0];



echo $array[0], '<br>';

theFunction($array);



echo $array[0], '<br>';



function theFunction($array) {

    $array[0] = 2;

}

Expected result:
----------------
you should get 1 and 1

Actual result:
--------------
instead you get 1 and 2!


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


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

Reply via email to