Jump to content

What's the point of "isset"?


kreut

Recommended Posts

Thank you both for your responses.  To clarify, then, if I want to see if a particular form is sent in, I would check if that particular submit button "isset"; and if I want to see if a particular form item is not empty, I would then use if (!$variable_of_interest) --- would this be the standard way of checking these two form items?

Link to comment
Share on other sites

More or less.  While I trust php's "isset" and it is useful for exactly what you describe, I don't trust php's "is true".  The big problem with it is that "0" is false.  But 0 is a perfectly good number, and it's most definitely "not empty", even though both !0 and empty(0) are TRUE!!  This quirk results in so many bugs, usually forms that mysteriously fail when particular input results in a 0 being tested for true-ness.

 

And the biggest gotcha with isset() is that false and 0 are "set" values, because "set" refers to the variable itself being set and not the value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.