projectIncomplete projectIncomplete - 1 year ago 61
HTTP Question

Do we always need to check if post and get variables are set before reading/using them?

Consider the following example:

if ( isset($_POST['type']) && 'page' == $_POST['type'] )

Do we need the

From what I've seen so far the following has the seem result:

if ( 'page' == $_POST['type'] )

Or can this cause problems in certain situations?

Answer Source

Using "isset" is right approach otherwise it will throw warning: "index type is undefined". Also it checks whether array is empty or not.

isset() function will serve the replacement of two functions

if(!empty(your_array) && array_key_exists('type',$POST['type']))

So use this check to avoid further complications

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download