ID:               48121
 User updated by:  feldkamp at gameforge dot de
 Reported By:      feldkamp at gameforge dot de
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Debian Etch 2.6.26
 PHP Version:      5.2.9
 New Comment:

In the example you bring up, the variables $a and $foo are not set
(null) => behaviour is as expected and as documented.

BUT: If you have the variable initialized (for example with false or an
empty string) your behaviour also come up (which it shouldn't in my
humble opinion)

if you use (boolean) true or a non-empty string, you get:
"Warning: Cannot use a scalar value as an array"

if you use (boolean) false or an empty string, you get:

boolean false
array
  'unsetKey' => null


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

[2009-04-30 15:16:42] j...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$a =& $foo[]; 

Where =& means that both $a and $foo[<next index>] should point to 
same place, and in your example they both point to null so:

var_dump($a, $foo);

Outputs:

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


For more info:
http://www.php.net/manual/en/language.references.whatare.php


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

[2009-04-30 13:51:57] feldkamp at gameforge dot de

Description:
------------
Using array-operator to access a non-existing key of a referenced
variable turns variables that are false or an empty string into arrays.

Reproduce code:
---------------
<?
$abc = false; // or ''
var_dump($abc);
$a = &$abc['unsetKey'];
var_dump($abc);
?>

Expected result:
----------------
Warning: Cannot use a scalar value as an array

Actual result:
--------------
boolean false

array
  'unsetKey' => null


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


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

Reply via email to