Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46763 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67666 invoked from network); 17 Jan 2010 06:17:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2010 06:17:08 -0000 Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:2502] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/F6-27028-26BA25B4 for ; Sun, 17 Jan 2010 01:17:07 -0500 Received: (qmail 61328 invoked by uid 98); 17 Jan 2010 06:17:11 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 (clamdscan: 0.88.7/10304. Clear:RC:1(127.0.0.1):. Processed in 0.069121 secs); 17 Jan 2010 06:17:11 -0000 Received: from localhost (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 17 Jan 2010 06:17:10 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Sun, 17 Jan 2010 00:17:10 -0600 (CST) Message-ID: <1527.98.193.1263709030.squirrel@www.l-i-e.com> In-Reply-To: <4B4DCC64.3030703@easyflirt.com> References: <4B4DCC64.3030703@easyflirt.com> Date: Sun, 17 Jan 2010 00:17:10 -0600 (CST) To: "mathieu.suen" Cc: internals@lists.php.net User-Agent: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Inconsistency redesign From: ceo@l-i-e.com ("Richard Lynch") 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