ID:          44128
 Updated by:  [EMAIL PROTECTED]
 Reported By: felipensp at gmail dot com
-Status:      Open
+Status:      Bogus
 Bug Type:    Scripting Engine problem
 PHP Version: 5.3CVS-2008-02-15 (CVS)
-Assigned To: 
+Assigned To: dmitry
 New Comment:

Your expectation is wrong:

In your second example two variables refer to the same NULL value.
(first element of array and variable $a)

Compare the output of the following two scripts

<?php
$x = array(&$a);
var_dump($x);
?>
Actual result:
--------------
array(1) {
  [0]=>
  &NULL
}

<?php
$x = array(&$a);
unset($a);
var_dump($x);
?>
Actual result:
--------------
array(1) {
  [0]=>
  NULL
}

In the third example you assign the array from second example to $a,
but $a is a reference, so the assignment will update the first element
of array too.

<?php
$b = array(&$a);
var_dump($b);
$a = $b;
var_dump($b);
?>
Actual result:
--------------
array(1) {
  [0]=>
  &NULL
}
array(1) {
  [0]=>
  &array(1) {
    [0]=>
    &array(1) {
      [0]=>
      *RECURSION*
    }
  }
}


All results are the same as they should be.


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

[2008-02-15 12:48:42] felipensp at gmail dot com

Description:
------------
Undefined variables non-reference/reference as item of an array has
different behavior.

Reproduce code:
---------------
1:
[EMAIL PROTECTED]:~/php5$ sapi/cli/php -r 'var_dump($a =array($a));'

2:
[EMAIL PROTECTED]:~/php5$ sapi/cli/php -r 'var_dump(array(&$a));'

3:
[EMAIL PROTECTED]:~/php5$ sapi/cli/php -r 'var_dump($a =array(&$a));'

Expected result:
----------------
2 and 3 as same result.

Actual result:
--------------
1:
array(1) {
  [0]=>
  NULL
}

2:
array(1) {
  [0]=>
  &NULL
}

3:
array(1) {
  [0]=>
  &array(1) {
    [0]=>
    &array(1) {
      [0]=>
      *RECURSION*
    }
  }
}


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


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

Reply via email to