SmArTaSs
05-09-2004, 08: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
}
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
}