I know that isset() checks to see if a variable exists. So if I have:
The variable exists, so will that return TRUE or FALSE? What about variables equal to NULL?PHP Code:$var = '';
if (isset($var)) {
}
Printable View
I know that isset() checks to see if a variable exists. So if I have:
The variable exists, so will that return TRUE or FALSE? What about variables equal to NULL?PHP Code:$var = '';
if (isset($var)) {
}
Ok isset will return True if the variable exists and false if it doesn't I am almost pos that isset has nothing to do with nulls. There is another function called isempty that returns true if the variable is empty. to this funciton empty is no value or null. so if you have a value that had nothing assigned to it or has a null value assigned to it the isempty function will return true. So if you are looking weather a variable is in use it is better to use isempty.
The PHP manual is the best place to find this trye of stuff. Its the easiest to follow programming manual I've ever read :)
Quote:
isset() function reference
Returns TRUE if var exists; FALSE otherwise.
If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant.
I have the downloadable manual. Use it all the time.
However, what you posted DOESN'T answer my question.
Which, I just checked the manual again. I was looking in the text for my answer before, but the example answered it:
Quote:
$var = '';
// This will evaluate to &true; so the text will be printed.
if (isset($var)) {
print "This var is set set so I will print.";
}
Sry I thought I answered u'r question fully I should have said that your example would return true as the varaiable is set to a blank space.
Thanks.