Re: PHP5 bloats the code
| From: | Curt Zirzow | Date: | Sat, 24 Apr 2004 14:41:40 +0000 |
| Subject: | Re: PHP5 bloats the code | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184521@lists.php.net to get a copy of this message | ||
* Thus wrote Marek Kilimajer (kilimajer@webglobe.sk):
> I just installed php5 (finaly :-)) and it does not throw any error nor
> warning. I think what you see is Notice, so the behavior did not change.
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
--
"I used to think I was indecisive, but now I'm not so sure."