Never use empty() I've been burned by this too many times.
It's behaviour around '0' and friends changed over the years. Some colleagues at a former job looked at me funny when they first heard my rant about this. Then they tracked down 3 separate bugs and fixed them, all deriving from the use of empty(). ymmv On Wed, January 13, 2010 7:36 am, mathieu.suen wrote: > Hi, > > I came across this: > > echo sizeof(array()); > echo sizeof(""); > $a = ""; > var_dump( empty($a)); > $a = array(); > var_dump(empty($a)); > > So funny! How something can have a size greater than 0 but still be > empty? > I think PHP is reinventing the inconsistency word. > > But then let assume that empty is just making a cast in array. > $a = ""; > empty($a) //true > empty((array)$a) //false > > Ok so empty is big ugly switch case on type. > > empty(0); //true > empty(45); //false > > Wooow reinventing emptiness on number.... > > -- Mathieu Suen > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people ask for gifts here. I just want you to buy an Indie CD for yourself: http://cdbaby.com/search/from/lynch -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php