# suggestion: empty() with infinite parameters like isset()

- Thread: https://externals.io/message/13412
- Original archive: https://news-web.php.net/php.internals/13412
- Started by Ron Korving on 2004-10-20T11:04:58+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13412 — Ron Korving — 2004-10-20T11:04:58+00:00

URL: https://externals.io/message/13412#13412

I think it would be a good idea to apply the idea of infinite parameters
that's been used with isset(), so one can test multiple variables:

if (empty($var1, $var2, $var3)) echo "data missing";

I hope someone will agree with me and add this feature.

Thanks,

Ron

---

## #13413 — Derick Rethans — 2004-10-20T11:07:58+00:00

URL: https://externals.io/message/13412#13413 · In reply to: #13412

> I think it would be a good idea to apply the idea of infinite parameters
> that's been used with isset(), so one can test multiple variables:
>
> if (empty($var1, $var2, $var3)) echo "data missing";

We discussed this before and we didn't want to agree if it should behave
like "each one should be empty" or "all should be empty". So we will not
add it.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13414 — Ron Korving — 2004-10-20T11:13:01+00:00

URL: https://externals.io/message/13412#13414 · In reply to: #13413

Okay, I don't wanna make remarks that may have already been made earlier,
but I think it should be "all should be empty", because it works exactly the
same for isset(), and apparently, a decision was made to give isset() that
feature.

Ron


"Derick Rethans" <derick@php.net> schreef in bericht
news:Pine.LNX.4.58.0410201307210.1991@localhost...
> 
>
> > […]
>
> We discussed this before and we didn't want to agree if it should behave
> like "each one should be empty" or "all should be empty". So we will not
> add it.
>
> Derick
>
> -- 
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13415 — Derick Rethans — 2004-10-20T11:16:08+00:00

URL: https://externals.io/message/13412#13415 · In reply to: #13414

> Okay, I don't wanna make remarks that may have already been made earlier,
> but I think it should be "all should be empty", because it works exactly the
> same for isset(), and apparently, a decision was made to give isset() that
> feature.

Right, but then your example would already no longer have worked:

	if (empty($var1, $var2, $var3)) echo "data missing";

so there is no point in adding it like that.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13416 — Ron Korving — 2004-10-20T11:21:07+00:00

URL: https://externals.io/message/13412#13416 · In reply to: #13415

Maybe it was a bad example. Writing "data missing" I was thinking that at
least one variable should be set.

Ron

"Derick Rethans" <derick@php.net> schreef in bericht
news:Pine.LNX.4.58.0410201315360.1991@localhost...
> 
>
> > […]
earlier,
> > […]
the
> > […]
that
> > […]
>
> Right, but then your example would already no longer have worked:
>
> if (empty($var1, $var2, $var3)) echo "data missing";
>
> so there is no point in adding it like that.
>
> Derick
>
> -- 
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13423 — Andi Gutmans — 2004-10-20T22:41:02+00:00

URL: https://externals.io/message/13412#13423 · In reply to: #13413

There is a big difference between isset() and empty() and it was discussed 
a lot in the past.
You'll see both sides to the coin after reading the archives. It's really a 
problem make a call on this one.

Andi

At 01:13 PM 10/20/2004 +0200, Ron Korving wrote:
>Okay, I don't wanna make remarks that may have already been made earlier,
>but I think it should be "all should be empty", because it works exactly the
>same for isset(), and apparently, a decision was made to give isset() that
>feature.
>
>Ron
>
>
>"Derick Rethans" <derick@php.net> schreef in bericht
>news:Pine.LNX.4.58.0410201307210.1991@localhost...
> > […]

---

## #13422 — Jevon Wright — 2004-10-20T22:44:03+00:00

URL: https://externals.io/message/13412#13422 · In reply to: #13416

How about anyempty($var1, $var2, $var3, ...) ?

Jevon

----- Original Message ----- 
From: "Ron Korving" <r.korving@xit.nl>
To: <internals@lists.php.net>
Sent: Thursday, October 21, 2004 12:21 AM
Subject: Re: [PHP-DEV] suggestion: empty() with infinite parameters like
isset()


> Maybe it was a bad example. Writing "data missing" I was thinking that at
> least one variable should be set.
>
> Ron
>
> "Derick Rethans" <derick@php.net> schreef in bericht
> news:Pine.LNX.4.58.0410201315360.1991@localhost...
> > […]
> earlier,
> > […]
exactly
> the
> > […]
> that
> > […]

---

## #13428 — Ron Korving — 2004-10-21T14:13:42+00:00

URL: https://externals.io/message/13412#13428 · In reply to: #13422

I'm not really anxcious to have an anyempty() function, but I do think
empty() should behalve like an allempty() just like isset() behaves like an
areallset(). I guess the "weirdness" is in the fact that isset() will give a
positive reply when something exists, while empty() gives a negative reply
when something exists. I guess this creates the confusion and would make the
allempty() functionality less likely to be used often. I guess people will
want to check more often if all their vars are set, and therefor an "or"
situation instead of "and" would be more suitable, because then you could
do: if (empty($var1, $var2, $var3)) echo "there's an empty var";
I'd personally prefer the "and" situation, but it's a fact that this would
make it far less useful than the "or". So I can see the confusion and the
reason to just stick with 1 parameter.

I guess there should just be a function like isset() which returns !empty().
Maybe it should be called isval() or something. Then it could be used for
several vars without confusion:
if (!isval($var1, $var2, $var3)) return "there's an empty var";

This would make sense to everybody I think, because like isset() it would be
an "and" situation.

Ron


"Jevon Wright" <jevon@jevon.org> wrote in message
news:008c01c4b6f6$4fd9a450$0a00a8c0@home.jevon.org...
> How about anyempty($var1, $var2, $var3, ...) ?
>
> Jevon
>
> ----- Original Message ----- 
> From: "Ron Korving" <r.korving@xit.nl>
> To: <internals@lists.php.net>
> Sent: Thursday, October 21, 2004 12:21 AM
> Subject: Re: [PHP-DEV] suggestion: empty() with infinite parameters like
> isset()
>
>
> > […]
at
> > […]
> exactly
> > […]
isset()
> > […]

---

## #13429 — Ron Korving — 2004-10-21T14:18:50+00:00

URL: https://externals.io/message/13412#13429 · In reply to: #13423

You're right, the only right way would be to introduce a new function like
the isval() I suggested in my reply to Jevon.

Ron

"Andi Gutmans" <andi@zend.com> wrote in message
news:5.1.0.14.2.20041020154028.036af970@localhost...
> There is a big difference between isset() and empty() and it was discussed
> a lot in the past.
> You'll see both sides to the coin after reading the archives. It's really
a
> problem make a call on this one.
>
> Andi
>
> At 01:13 PM 10/20/2004 +0200, Ron Korving wrote:
> > […]
the
> > […]
that
> > […]
parameters
> > […]
behave
> > […]
not
> > […]

---

## #13430 — David Vance — 2004-10-21T15:02:38+00:00

URL: https://externals.io/message/13412#13430 · In reply to: #13428

if(any_empty($var1, $var2, $var3)) return "there's an empty var";
if(!any_empty($var1, $var2, $var3)) return "there's no empty vars";

if (all_set($var1, $var2, $var3)) return "all vars are set";
if (!all_set($var1, $var2, $var3)) return "there's an unset var";

but how would you find out which var's, if any, are empty or not set?
otherwise, would seem not very useful...

if(!all_set($var1, $var2, $var3)){
  if(!isset($var1)){
    echo 'it was 1';
  }
  if(!isset($var2)){
    echo 'it was 2';
  }
  if(!isset($var3)){
    echo 'it was 3';
  }
}


On Thu, October 21, 2004 9:13 am, Ron Korving said:
> I'm not really anxcious to have an anyempty() function, but I do think
> empty() should behalve like an allempty() just like isset() behaves like
> an
> areallset(). I guess the "weirdness" is in the fact that isset() will give
> a
> positive reply when something exists, while empty() gives a negative reply
> when something exists. I guess this creates the confusion and would make
> the
> allempty() functionality less likely to be used often. I guess people will
> want to check more often if all their vars are set, and therefor an "or"
> situation instead of "and" would be more suitable, because then you could
> do: if (empty($var1, $var2, $var3)) echo "there's an empty var";
> I'd personally prefer the "and" situation, but it's a fact that this would
> make it far less useful than the "or". So I can see the confusion and the
> reason to just stick with 1 parameter.
>
> I guess there should just be a function like isset() which returns
> !empty().
> Maybe it should be called isval() or something. Then it could be used for
> several vars without confusion:
> if (!isval($var1, $var2, $var3)) return "there's an empty var";
>
> This would make sense to everybody I think, because like isset() it would
> be
> an "and" situation.
>
> Ron
>
>
> "Jevon Wright" <jevon@jevon.org> wrote in message
> news:008c01c4b6f6$4fd9a450$0a00a8c0@home.jevon.org...
> > […]
> at
> > […]
> isset()
> > […]

---

## #13432 — Derick Rethans — 2004-10-21T15:31:32+00:00

URL: https://externals.io/message/13412#13432 · In reply to: #13430

> but how would you find out which var's, if any, are empty or not set?
> otherwise, would seem not very useful...

Right, please take this discussion off-list as we have had it in the
past and came to the conclusion that there is no way to do this in a
sane way.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org
