Curt Zirzow wrote:
Here is the offending situation:

<?php

/* E_NOTICE: undefined index, returns false */
unset($a);
echo is_array($a['foo']['asdf']);

/* returns false */
$a = 'asdf';
echo isset($a['foo']['asdf']);

/* returns false */
$a = array('foo' => 'asdf');
echo is_array($a['foo']['asdf']);

/* E_ERROR Invalid offset */
$a = 'asdf';
echo is_array($a['foo']['asdf']);

The last one is the biggie, the solution of course is to have
something like:

if (isset($a['foo']['asdf']) &&
    is_array($a['foo']['asdf']) {

This is a big BC issue, IMO, and might be worth asking internals
why the E_ERROR is given vs. a E_WARNING.


Curt

Well, what I always know about my variables is if they are arrays or scalar ;) And I don't consider warning to be much nicer then error



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to