Re: if (empty versus if (isset

[email protected] (Jim Giner)
Newsgroups php.general
Message-ID <[email protected]>
Basically it tells a savvy programmer whether or not his logic has 
caused the var in question to "exist".  Many times it is important 
simply to know that, not what the var contains, which can lead to an 
error in processing.

The isset() will tell you that "yes, I have this variable", letting you 
then correctly interpret the contents.  If a $_POST var is not set 
(meaning the user made no input to it), the use of empty() will insist 
on telling you that the var is empty even tho it really was not provided 
by the user (assuming that you don't get an error msg for having an 
invalid index in the POST array).

They seem to be needlessly redundant, but in fact do provide knowledge 
for those seeking it.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.