On Tue, Jul 2, 2013 at 9:40 AM, Thomas Gries
<mail(a)tgries.de> wrote:
PHP codestyle question re. isset(
$array['key'][0] ) versus
array_key_exists( 0, $array['key'] )
On a recent patch [1], we had a discussion what is - or may be - better
* isset( $array['key'][0] )
* array_key_exists( 0, $array['key'] )
In my opinion, isset() is usually clearer and "more natural", in part
because you don't have to guess/memorize the order of parameters (which is
haystack again, and which is needle?).
There is however a functional difference: if your array can contain null as
a valid value, then isset() can give you a false negative. So beware...
-- brion
In the present case of E:OpenID, I need to check the data of an array
which has been read in from the Provider.
In my view, it appears to be more secure to use array_key_exists( ).