From:             tomas dot matousek at matfyz dot cz
Operating system: WinXP
PHP version:      5.0.0RC2
PHP Bug Type:     Scripting Engine problem
Bug description:  Operator $x[$y] behavior is incorrect

Description:
------------
Why does operator [] create a new array when applied on boolean FALSE and
doesn't do so  when applied on integer 0? One of that is IMHO wrong.
Either this operator should create a new array on everything that is
empty() or it should fail on all scalar types and make a new array only
from empty string "" or NULL or uninitialized variable.


Reproduce code:
---------------
$a = 0;
$a[10] = 1;
var_dump($a);

$b = false;
$b[10] = 1;
var_dump($b);


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


Actual result:
--------------
array(1) {
  [10]=>
  int(1)
}

Warning:  Cannot use a scalar value as an array ...


-- 
Edit bug report at http://bugs.php.net/?id=28503&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28503&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28503&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28503&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28503&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28503&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28503&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28503&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28503&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28503&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28503&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28503&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28503&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28503&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28503&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28503&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28503&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28503&r=float

Reply via email to