...

View Full Version : What is the difference between these statements?



SmArTaSs
05-09-2004, 09:18 PM
if(!isset($_POST["var"])){ }
if($_POST["var"]==""){ }
if(!$_POST["var"]){ }
My question is, what is the difference between each one?

I am using !isset($_POST["var"]) || $_POST["var"]=="" to see if they were not entered. I am doing this so that I can show an error, then return the form to the user.

BUT, I have a feeling I could just get rid of one of them.
Would the following two statements work the same?


if(!isset($_POST["var"]) || $_POST["var"]==""){
// Show error and form
}

if($_POST["var"]==""){
// Show error and form
}

firepages
05-10-2004, 03:18 AM
in the context of checking for empty form fields, empty normally covers the bases...


<?if( empty( $_POST['var'] ) ){}?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum