Re: Inconsistency of empty() and isset() ?
| From: | itrebal at gmail dot com | Date: | Mon, 17 Apr 2006 01:08:48 +0000 |
| Subject: | Re: Inconsistency of empty() and isset() ? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-22807@lists.php.net to get a copy of this message | ||
When I'm validating form data, there are many occasions (more than
not) that I require most of them to be completed, and not left blank.
In which case you would do:
if(empty($_GET['var1'], $_GET['var2'], $_GET['var3'])){
//Display error, yadda yadda
}
as aposed to
if(empty($_GET['var1']) || empty($_GET['var2']) ||
empty($_GET['var3'])){
//Display error, yadda yadda
}
which is a much cleaner and simpler method. Doing it the other way (AND/OR)
doesn't seem to have many applications that I can see.
On 4/15/06, itrebal@gmail.com <itrebal@gmail.com> wrote:
>
> The following is a direct excerpt from the PHP manual on empty, and isset:
> bool *empty* ( mixed var )
> bool *isset* ( mixed var [, mixed var [, ...]] )
> Is there a reason empty does not allow multiple variables at a time, as
> isset? Was there thought behind it, or is it just an inconsistency?
>
--
------------------------------------
Graham Christensen
www.itrebal.com
www.iamgraham.net