|
-
Oct 14th, 2003, 06:58 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] isset() Question
I know that isset() checks to see if a variable exists. So if I have:
PHP Code:
$var = '';
if (isset($var)) {
}
The variable exists, so will that return TRUE or FALSE? What about variables equal to NULL?
Last edited by The Hobo; Oct 15th, 2003 at 01:53 PM.
-
Oct 14th, 2003, 08:12 PM
#2
Lively Member
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.
===============
Tek
===============
-
Oct 14th, 2003, 10:08 PM
#3
Member
The PHP manual is the best place to find this trye of stuff. Its the easiest to follow programming manual I've ever read 
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.
-
Oct 14th, 2003, 11:15 PM
#4
Thread Starter
Stuck in the 80s
I have the downloadable manual. Use it all the time.
However, what you posted DOESN'T answer my question.
-
Oct 14th, 2003, 11:16 PM
#5
Thread Starter
Stuck in the 80s
Which, I just checked the manual again. I was looking in the text for my answer before, but the example answered it:
$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.";
}
-
Oct 15th, 2003, 06:03 AM
#6
Lively Member
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.
===============
Tek
===============
-
Oct 15th, 2003, 01:50 PM
#7
Thread Starter
Stuck in the 80s
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|