Re: Re: How to do type/existence checking in PHP5

From: Date: Tue, 27 Apr 2004 10:14:29 +0000
Subject: Re: Re: How to do type/existence checking in PHP5
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-184744@lists.php.net to get a copy of this message
if(is_array($a) && is_array($a['foo']['bar']['doo']))
if I set $a['foo'] to be an object it fails on line 6, if I set it to be an integer or float it doesn't fail. I find that buggy.
Why, the function is is_array, so it checks whether it is an array, and an object is not an array, is it? An integer can be seen as a one-dimensional array with size 1. You could test the functions isset() and array_key_exists().

« previous php.general (#184744) next »