Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25319 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95644 invoked by uid 1010); 11 Aug 2006 14:05:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 95628 invoked from network); 11 Aug 2006 14:05:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2006 14:05:17 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.132 msa2-mx.centurytel.net Linux 2.4/2.6 Received: from ([209.142.136.132:37915] helo=msa2-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id A9/74-28296-99E8CD44 for ; Fri, 11 Aug 2006 10:05:14 -0400 Received: from pc1 (d19-198.rt-bras.wnvl.centurytel.net [69.179.146.198]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k7BE58JS018999; Fri, 11 Aug 2006 09:05:08 -0500 Message-ID: <018701c6bd4f$28163d50$0201a8c0@pc1> To: , "Jochem Maas" References: <005101c6b930$83f30b30$0201a8c0@pc1> <00fa01c6bd37$d61d1940$0201a8c0@pc1> <20060811141931.2ef39365@pierre-u64> <44DC84C0.7040807@iamjochem.com> Date: Fri, 11 Aug 2006 09:05:09 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: Re: [Simplistic End User View] Re: [PHP-DEV] is_numeric_string causes function inconsistency From: php_lists@realplain.com ("Matt W") Hi Jochem, Leading whitespace is already allowed with PHP's is_numeric() function (and corresponding internal one), math operations, etc. Only when it precedes .123 or -.123 does the behavior change. :-) Matt ----- Original Message ----- From: "Jochem Maas" Sent: Friday, August 11, 2006 Pierre wrote: >> is_numeric(' .123') // bool(false) > > this one should return true. as Pierre mentions further down changing this behaviour could cause pots of problems for existing code. from an enduser POV having is_numeric(' .123') return true (and therefore having maths operations using ' .123' use that string as if it was '.123' would be tantamount to doing: $v = " .123"; $v = trim($v); var_dump(is_numeric($v), ($v + 0)); In order to be able to move forward and allow for leading spaces in numeric strings maybe an ini setting could be used, one that defaults to false: trim_numeric_strings_before_usage = 0; such a setting if true would essentially trim space (like the trim() function does) form strings before they were checked (by is_numeric) and before being used in calculations. in php6 the default of this ini setting could be changed to true (which would offer quite some time to check for possible unforeseen problems and eventually in php7,8,9 the setting could dissappear entirely once the community is satisfied any/all problems have been dissipated. I have no idea if this is feasable or desirable (I'm aware of the animosity towards new ini settings!) but it might offer a potential resolution between moving forward and protecting muppets like myself from 'strange behaviour' related to autocasting of numeric strings. rgds, Joche,