Hi all,

I'd expect the following code to throw a notice/warning:

$x = true;
$y = $x['foo'];

It executes completely silently.
$y is NULL afterwards, which is expected, since the right hand side of
the assignment is undefined.

If $x was an array (e.g. empty array), a E_NOTICE would be emitted.

Can anyone shed a light on this behaviour? If accessing non existing
array keys is worth a notice, shouldn't accessing an array index on a
non array be worth a notice as well (maybe even a warning)?

The other way round emits a warning (i.e. writing to an array key on a
non array):

$x = true;
$x['foo'] = 'bar';

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

Thanks for any insight,

greetings

Nico

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to