Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46689 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47628 invoked from network); 13 Jan 2010 14:00:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2010 14:00:53 -0000 Authentication-Results: pb1.pair.com header.from=jille@hexon.cx; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jille@hexon.cx; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hexon.cx from 82.94.237.14 cause and error) X-PHP-List-Original-Sender: jille@hexon.cx X-Host-Fingerprint: 82.94.237.14 mulgore.hexon-is.nl Received: from [82.94.237.14] ([82.94.237.14:45071] helo=mulgore.hexon-is.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/BE-00773-112DD4B4 for ; Wed, 13 Jan 2010 09:00:52 -0500 Received: from adidas.hexon-nijmegen.nl (gw.hexon-nijmegen.nl [82.93.241.107]) by mulgore.hexon-is.nl (8.14.3/8.14.3) with ESMTP id o0DE0eYC022953; Wed, 13 Jan 2010 15:00:40 +0100 Received: from [10.0.0.142] (HENK.hexon-nijmegen.nl [10.0.0.142]) by adidas.hexon-nijmegen.nl (8.14.3/8.14.3) with ESMTP id o0DE0alE013161; Wed, 13 Jan 2010 15:00:36 +0100 Message-ID: <4B4DD201.7000006@hexon.cx> Date: Wed, 13 Jan 2010 15:00:33 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: Etienne Kneuss CC: "mathieu.suen" , internals@lists.php.net References: <4B4DCC64.3030703@easyflirt.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Hexon-MailScanner-Information: Please contact the ISP for more information X-Hexon-MailScanner-ID: o0DE0eYC022953 X-Hexon-MailScanner: Found to be clean X-Hexon-MailScanner-From: jille@hexon.cx X-Hexon-MailScanner-Watermark: 1263996041.79235@I5t1NhUgkluCOLHb3un26Q Subject: Re: [PHP-DEV] Inconsistency redesign From: jille@hexon.cx (Jille Timmermans) var_dump((array)""); Results in: array(1) { [0]=> string(0) "" } And 'array("")' is not empty. -- Jille Op 13-1-2010 14:50, Etienne Kneuss schreef: > Hello, > > On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen > wrote: >> Hi, >> >> I came across this: >> >> echo sizeof(array()); >> echo sizeof(""); >> $a = ""; > > php.net/count: > "If var is not an array or an object with implemented Countable > interface, 1 will be returned. There is one exception, if var is NULL, > 0 will be returned." > >> var_dump( empty($a)); >> $a = array(); >> var_dump(empty($a)); > > php.net/empty > > empty($var) is basically an !isset($var) || !$var > > it's not related to count in anyway. > >> >> So funny! How something can have a size greater than 0 but still be empty? >> I think PHP is reinventing the inconsistency word. > > I think such comments are pretty useless. Try coming with a viable > solution as a patch instead. > >> >> But then let assume that empty is just making a cast in array. > > If you assume wrong, you can derive all kind of madness. > >> $a = ""; >> empty($a) //true >> empty((array)$a) //false >> >> Ok so empty is big ugly switch case on type. > > No, it's a boolean check, with type juggling involed, see above. > >> >> 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 >> >> > > >