Strange action with =&

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

 



I'm looping through an array and I did this:

    $rate =& $mydata[$prefix];

Now, in some cases $mydata[$prefix] wasn't set/defined, so I expected $rate
to not be defined, or at least point to something that wasn't defined.

Instead, PHP 5.1.6 set $mydata[$prefix] to nothing.

If I had:

    $mydata[1] = 3;
    $mydata[3] = 2;
    $mydata[5] = 1;

And did a loop from $i=1; $i++; $i<=5 I'd get:

    $mydata[1] = 3;
    $mydata[2] = ;
    $mydata[3] = 2;
    $mydata[4] = ;
    $mydata[5] = 1;

Is this expected?  A bug?  Fixed in 5.2.0?  I know I shouldn't set a
reference to a variable that doesn't exist, but the expected result is a
warning/error, not for PHP to populate an array.

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@xxxxxxxxxxxxx                             http://www.purplecow.com/
---------------------------------------------------------------------------

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux