[2002年12月13日 12:00 UTC] henrik dot gebauer at web dot de
I create an array an then a reference to an element of that array.
Then the array is passed to a function (by value!) which changes the value of the element.
After that, the global array has also another value.
I would expect this behaviour if I passed the array by reference but I did not.
<?php
$array = array(1);
$reference =& $array[0];
echo $array[0], '<br>';
theFunction($array);
echo $array[0], '<br>';
function theFunction($array) {
$array[0] = 2;
}
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002年12月13日 12:42 UTC] msopacua@php.net
[2002年12月13日 12:50 UTC] moriyoshi@php.net
[2002年12月13日 14:51 UTC] moriyoshi@php.net
[2002年12月18日 03:25 UTC] msopacua@php.net
[2004年04月16日 22:59 UTC] php dot devel at homelinkcs dot com
[2004年04月17日 17:59 UTC] nlopess@php.net
[2004年04月22日 01:34 UTC] php dot devel at homelinkcs dot com
[2004年04月25日 20:32 UTC] nlopess@php.net
[2004年05月03日 23:46 UTC] php dot devel at homelinkcs dot com
[2004年07月26日 17:16 UTC] vrana@php.net
|
||||||||||||||||||||||||||||||||||||