Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21229 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84894 invoked by uid 1010); 15 Dec 2005 12:47:57 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84879 invoked from network); 15 Dec 2005 12:47:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2005 12:47:57 -0000 X-Host-Fingerprint: 64.233.162.203 zproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.162.203:56222] helo=zproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id A4/8B-23096-CF561A34 for ; Thu, 15 Dec 2005 07:47:56 -0500 Received: by zproxy.gmail.com with SMTP id v1so421293nzb for ; Thu, 15 Dec 2005 04:47:54 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=n+hzf5h5c+Z4tJmB/azQQv7p9usnSJB4ES46KXBIkSip1vM4EZhMeos3xdN2cG/M3gQ3rqN/F+9/lEOJ/Non8Yf/BF5DoJmPSYT3ETUFJIrflLx6cD5ypfZN6L7eoozTji3hF4QyiMSGgGHYG45IplkkZHcr1wPMBZ/MtHfoATo= Received: by 10.37.22.8 with SMTP id z8mr1920135nzi; Thu, 15 Dec 2005 04:47:54 -0800 (PST) Received: by 10.37.21.1 with HTTP; Thu, 15 Dec 2005 04:47:54 -0800 (PST) Message-ID: <5c2874720512150447w319ce3e2n204d319d15329722@mail.gmail.com> Date: Thu, 15 Dec 2005 06:47:54 -0600 To: Greg Beaver Cc: php-dev In-Reply-To: <43A0F0BB.6080009@chiaraquartet.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <43A0F0BB.6080009@chiaraquartet.net> Subject: Re: [PHP-DEV] why is '01' == '1.'? From: jason.sweat@gmail.com (Jason Sweat) On 12/14/05, Greg Beaver wrote: > In this case, a string is explicitly being compared to a string, and yet > both are being converted to an int prior to comparison. I can > understand that implicit type conversion is needed when comparing > strings to ints, but this can be dangerous. phpDocumentor, for instance > uses this code: > > if (in_array(substr($ltrimword, 0, 2), array('1.', '0.'))) Perhaps if (preg_match('/^[10]\./',$ltrimword)) would be both more concise and express your intent better? Regards, Jason http://blog.casey-sweat.us/