Jump to content

double checking recieved values, good practice?


logansama

Recommended Posts

Good day gents and gentets!

 

I just wanted to ask the opinion of others on the following:

 

When recieveing values, usually through $_POST or $_GET one would determain if a value was actually received by doing a isset(..) on the value element or just the whole array. But would you aggree or disagree that it would be good practice to also have a empty(..) check on the same value?

 

I have had incidents where the value/variable etc received was set but happened to be empty.

 

I wonder if i should make it a required practice to always do both a isset() and empty()?

 

your input will be values! :)

Personally, i just do empty() if it needs to be a valid value since it checks whether is it set and if it has a true value.  If i just want to know if it is set then i just use isset(since it is slightly faster). Using both is pointless since empty() does the same thing as isset(), just does more than isset().

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.