IT Community - Software Programming, Web Development and Technical Support

what is the Difference between isset() and empty() .

This is a discussion on what is the Difference between isset() and empty() . within the PHP Programming forums, part of the Web Development category; hi, what is the Difference between isset() and empty() ....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-18-2007, 08:52 AM
raj raj is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
raj is on a distinguished road
Default what is the Difference between isset() and empty() .

hi,

what is the Difference between isset() and empty() .
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-19-2007, 12:58 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: what is the Difference between isset() and empty() .

hi,
isset() - will tell you is a varaible has been defined. Sometimes it will return true even if the varable has an empty value.

empty() - check for the value is set for the variable. it returns true if the value is "0"

For some PHP type comparison please see this

PHP: PHP type comparison tables - Manual
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-19-2007, 01:03 AM
P.Sathiya P.Sathiya is offline
D-Web Trainee
 
Join Date: Mar 2007
Posts: 16
P.Sathiya is on a distinguished road
Thumbs up Re: what is the Difference between isset() and empty() .

Isset() checks if a variable has a value including ( Flase , 0 , or Empty string) , But not NULL.
Returns TRUE if var exists; FALSE otherwise.

On the other hand the empty() function checks if the variable has an empty value empty string , 0, NULL ,or False. Returns FALSE if var has a non-empty and non-zero value.
Comparison example on both isset() and empty()
<?php
$var = 0;

// Evaluates to true because $var is empty
if (empty($var)) {
echo '$var is either 0, empty, or not set at all';
}

// Evaluates as true because $var is set
if (isset($var)) {
echo '$var is set even though it is empty';
}
?>
For more information and examples visit the following links.

PHP: isset - Manual

PHP: empty - Manual
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove empty or null rows from a dataview it.wily C# Programming 2 02-10-2008 07:34 AM
Empty a recycle bin in C# garunprasad C# Programming 2 08-25-2007 02:56 AM
Outlook - Mail subject empty alert priyan Microsoft 1 07-11-2007 07:57 AM


All times are GMT -7. The time now is 03:13 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0