reference variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i have this script

<?php
$x = 1;
$y = 2;
$a1 = array(&$x, &$y);
$a2 = array($x, $y);
$a2[0] = 3;
print_r($a1);
print_r($a2);
?>

i am expecting

Array
(
    [0] => 3
    [1] => 2
)
Array
(
    [0] => 3
    [1] => 2
)


while i m getting

Array
(
    [0] => 1
    [1] => 2
)
Array
(
    [0] => 3
    [1] => 2
)


any ideas why this is happening?? or am i missing something..?
the same is the case when i replace
$a2[0] = 3; with
$a1[0] = 3;
$x = 3;

Kranthi.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux