Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19751 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26232 invoked by uid 1010); 26 Oct 2005 23:17:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26216 invoked from network); 26 Oct 2005 23:17:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Oct 2005 23:17:19 -0000 X-Host-Fingerprint: 69.64.38.41 bluga.net Linux 2.5 (sometimes 2.4) (4) Received: from ([69.64.38.41:39142] helo=bluga.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 58/70-22886-E7E00634 for ; Wed, 26 Oct 2005 19:17:19 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by bluga.net (Postfix) with ESMTP id BF18921CA80; Wed, 26 Oct 2005 18:18:22 -0500 (CDT) Received: from bluga.net ([127.0.0.1]) by localhost (bluga.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 17718-08; Wed, 26 Oct 2005 18:18:22 -0500 (CDT) Received: from [192.168.0.104] (CPE-67-48-78-96.neb.res.rr.com [67.48.78.96]) by bluga.net (Postfix) with ESMTP id 6149321C1B2; Wed, 26 Oct 2005 18:18:22 -0500 (CDT) Message-ID: <43600E77.5080207@chiaraquartet.net> Date: Wed, 26 Oct 2005 18:17:11 -0500 User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ilia Alshanetsky CC: Jani Taskinen , internals@lists.php.net References: <4e36d31d0510261018t639c472x9efaaf7af61a9ddb@mail.gmail.com> <435FDC41.30207@php.net> <435FF414.3000303@prohost.org> In-Reply-To: <435FF414.3000303@prohost.org> X-Enigmail-Version: 0.92.1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new using ClamAV at bluga.net Subject: Re: [PHP-DEV] Re: foreach with null From: greg@chiaraquartet.net (Greg Beaver) Ilia Alshanetsky wrote: > Greg Beaver wrote: > >>amen, this behavior makes no sense even though sizeof() is an alias to >>count(). sizeof('this') and sizeof('this long thing') are both 1, which >>makes no sense. I would go so far as to say a E_NOTICE is more >>appropriate than E_STRICT - you should only be using count() for >>arrays/objects. > > > Actually this result makes perfect sense since type conversion changes > string into array('your string') and does a count of that, which is 1. Yes, it makes sense from this perspective, but from a real-life programming perspective it is 1) useless - count() provides no useful information about strings 2) potentially buggy. For instance, PEAR's XML_Unserializer (XML_Serializer package) represents XML elements with simple text node children as a string, and tags with anything else (attributes, child elements) as an array. Improperly written code that uses count() without checking is_array() would happily run with no warning whatsoever. However, imho it would make PHP more robust if the logical error condition were also a language error, that's all. Greg