Hi,
I am wondering if I can have a control structure based just on whether or not a variable has a certain value where there might be times when that variable doesn't exist or whether I need to base it on whether or not the variable actually exists too.
For example can I just have (bearing in mind $var may not exist):
if ($var == 'y')
{
etc.
}
OR
must/should it be:
if (isset($var) && $var == 'y')
{
etc.
}
When testing such a script as the first example on my local-host web server it seems fine even if the variable tested doesn't exist as it just doesn't go into the if code-block but I think I have seen examples of where both are used so am wondering whether some server environments would throw-up errors or cause problems if used the first example when the variable didn't exist at that time.
Thanks for any help in advance.
AM


