projectIncomplete projectIncomplete - 5 months ago 21
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?


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