RE: [PHP-DEV] [DISCUSSION] Make empty() a Variadic

From: Date: Fri, 13 Feb 2015 11:41:43 +0000
Subject: RE: [PHP-DEV] [DISCUSSION] Make empty() a Variadic
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-82606@lists.php.net to get a copy of this message
Hi, > From: ajf@ajf.me> > * I assume Thomas actually meant “where if any arguments passed in are considered empty, then > *true* is returned”, i.e. (empty($a) || empty($b) || empty($c)) > > Sorry for the confusion. > > I think the || behaviour is the most useful, as it’s the analogue of isset’s. So !empty($a, > $b, $c) would work similarly to isset($a, $b, $c), and similarly, !isset($a, $b, $c) would work > similarly to empty($a, $b, $c). > > But that’s just my opinion. :) > -- > Andrea Faulds > http://ajf.me/ Yeah, my mistake. That's what I meant - empty will return TRUE if *any* of its arguments are considered empty, and FALSE otherwise. So the following two pieces of code are analogous: # this:if (empty($a) || empty($b) || empty($c)) {// error here} # is the same as this:if (empty($a, $b, $c)) {// error here} # and this:if (!empty($a) && !empty($b) && !empty($c)) {// all good!} # is the same as this:if (!empty($a, $b, $c)) {// all good!} Sorry for the confusion :p -Tom

« previous php.internals (#82606) next »