On Wed, Jul 3, 2013 at 12:47 AM, Brion Vibber <[email protected]> wrote:
> On Tue, Jul 2, 2013 at 9:40 AM, Thomas Gries <[email protected]> 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...

btw it'll silently return false without any error and make it
sometimes difficult to debug when you mistyped isset( $array['key'][0]
) as isset( $arrray['key'][0] ) accidentially...

-Liangent

>
> -- brion
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to