if($var) vs. if(isset($var))
Hi,
When checking whether the submit button is pressed or not,
if I use
PHP Code:
if (isset($_POST['submit']))
it works fine. If I use
PHP Code:
if ($_POST['submit'])
it gives an "Undefined index" notice, which means I need isset() for this check.
When checking whether the username and password fields are empty or not, both of the following works fine.
PHP Code:
if (isset($_POST['username']) && isset($_POST['password']))
PHP Code:
if ($_POST['username'] && $_POST['password'])
which means I don't need isset() for this check.
My question is, should I always use isset() for checking variables or is it ok not to use it where it is not required?