Hi!

On 11/23/11 6:14 AM, Daniel Convissor wrote:
To me, this is the bug.  $a['blah'] does not exist.  An undefined index

If it's a bug, this bug was in PHP since forever, nothing new here.

notice should be raised.  The key "blah" should not be converted to 0.
The following two things should behave the same:

$b = array('exists' =>  'foo');
echo $b['blah'] . "\n";

$a = 'foo';
echo $a['blah'] . "\n";

No they should not. First is array access, second is string offset access, totally different ops. That's like saying + on arrays should calculate the sum of all array elements because + on numbers calculates the sum. Operators have different meanings for different types, it has always been so in all languages. One could argue that string access with non-string should produce a notice, but probably if we added that a lot of people would come out to complain we broke their perfectly working code ;)
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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

Reply via email to