Re: PHP5 bloats the code

From: Date: Sat, 24 Apr 2004 17:51:44 +0000
Subject: Re: PHP5 bloats the code
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-184529@lists.php.net to get a copy of this message
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

« previous php.general (#184529) next »