NYCPHP Meetup

NYPHP.org

[nycphp-talk] Difference between isset() and empty() .

David Mintz vtbludgeon at gmail.com
Fri May 18 10:31:53 EDT 2007


Yes but you certainly can check ANY variable with isset(), not just
superglobal arrays.

In addition to the technical differences between empty() and isset(), I
would add that empty() is quite convenient and under-utilized. Consider

if (isset($_GET['q'] && $_GET['q']) { ........ }

versus

if (!empty($_GET[) { ....... }


empty() also has a cooler, more Zen-like name.


On 5/18/07, David Krings <ramons at gmx.net> wrote:
>
> >
> isset() checks if a key exists in a server array such as $_SESSION or
> $_POST regardless of the value, which can be NULL or an empty string. I
> never used empty(), but just by the name of it that function checks if
> the value of a given variable or array key is considered "nothing" for
> the respective variable type.




-- 
David Mintz
http://davidmintz.org/

Just a spoonful of sugar helps the medicine go down
In a most delightful way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070518/eb98b85b/attachment.html>


More information about the talk mailing list