Hey all, just a quick question on something i've been wondering about for a long while now...
Quite often in my scripts i'll have to check if a variable has a value assigned to it... ie, that it's been set, and has some sort of a value in it. I know of three ways to test this and i usually end up using a mix of them:
if (empty($var)) {
print 'variable is empty';
}
if (!isset($var)) {
print 'variable is empty';
}
if ($var == NULL) {
print 'variable is empty';
}
What are the differences between these three methods? If i just want to check that a variable has a value in it which is the best to use?
usually i use something like this:
if (isset($var) && $var != NULL) {
// do stuff
}
But i've never really been sure if that's the right way to do it, or if there's a better way.
Thanks,
-ben