From:             wojtek77 at o2 dot pl
Operating system: Windows 7
PHP version:      Irrelevant
Package:          Arrays related
Bug Type:         Bug
Bug description:problem with function & reference

Description:
------------
A variable which is an array pass to function as value but this variable
behaves 
as pass by reference.

Test script:
---------------
/*
 * an argument $bar pass to function by value not by reference
 */
function foo($bar)
{
        $bar[0] = 'error';
}

/*
 * any array variable
 */
$bar[0] = 'OK';
print_r($bar); echo '<br />';

 /*
  * it will causes an error in function foo()
  * create any reference to value of array
  */
$any_reference = & $bar[0];

/*
 * although the argument $bar pass to function by value
 * it behaves as argument $bar pass to funkction by reference
 */
foo($bar);
print_r($bar); echo '<br />';

Expected result:
----------------
Array ( [0] => OK ) 

Actual result:
--------------
Array ( [0] => error ) 

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63318&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63318&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63318&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63318&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63318&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63318&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63318&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63318&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63318&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63318&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63318&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63318&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63318&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63318&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63318&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63318&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63318&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63318&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63318&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63318&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63318&r=mysqlcfg

Reply via email to