NYCPHP Meetup

NYPHP.org

[nycphp-talk] Handling empty values in hashes

Mark Armendariz lists at enobrev.com
Fri Jul 18 12:16:24 EDT 2008


Daniel Convissor wrote:
> Paul:
>
> On Thu, Jul 17, 2008 at 02:58:00PM -0400, paul at devonianfarm.com wrote:
>   
>> isset($array[$key])
>> how's that different from array_key_exists?
>>     
>
> isset() thinks NULL is not set.  Similarly, empty() can be used for stuff 
> like this, but of course, it thinks NULL, 0, FALSE and "" are all the 
> same.  Which function to use depends on how your program needs to work.  
>
>   
I also prefer array_key_exists - mostly due to being exactly what I need 
when I use it (checking for a key, though I recall seeing somewhere 
(sorry no source, but should be easy enough to test), that isset is 
somewhat faster than array_key_exists.

Anyways, I like the article, but I noticed 2 errors.

You forgot an "I" in "mplementations" in the 2nd paragraph.

And you have an extra closing parentheses in one of your early examples:
[11] if ($_GET["q"])) {  // <-- Extra Closing Paren.
[12]     throw new InvalidInputException("You must specify a query");
[13] }

Have a great weekend NYPHP!

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080718/92a574f1/attachment.html>


More information about the talk mailing list