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

From: Date: Fri, 13 Feb 2015 12:11:54 +0000
Subject: RE: [PHP-DEV] [DISCUSSION] Make empty() a Variadic
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-82607@lists.php.net to get a copy of this message
Hi Reeze, > From: reeze@php.net > > For example: echo $a, $b, $c, & empty($a, $b, $c), they are treated equal, > > if the empty() means if any one of them is empty then result is TRUE, the > advantage of it disappeared: > > if (empty($a, $b, $c)) { > // you might want to check it again. > if (empty($a)) { > //blah blah. > } else if (empty($b)) { > > } > } > Having empty() return TRUE if *all* arguments are empty, and FALSE otherwise doesn't seem to be as useful (at least from what I've seen in code). It's less common to see: if (empty($a) && empty($b) && empty($c)) {} than: if (empty($a) || empty($b) || empty($c)) {} Plus then the semantics wouldn't be inline with isset(), which could be somewhat confusing to users. > > -- > Reeze Xia > http://reeze.cn Thanks, Tom

« previous php.internals (#82607) next »