Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60511 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17614 invoked from network); 7 May 2012 18:07:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2012 18:07:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:63653] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/10-16305-87F08AF4 for ; Mon, 07 May 2012 14:07:52 -0400 Received: by yenl2 with SMTP id l2so1203042yen.29 for ; Mon, 07 May 2012 11:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=HHI/1Nx3xikMsAVmHI2dK7EIhyjZ8SCR4cTq91N41Ng=; b=M2tviT30sZ3BF9dZH03xBeRLcA7kTUbr3Ka4iXucKi+bw8MCTLwVilCGuAGLzBoJwg roqDmU6XLsaBFBnSVcBvt7GOif+WGu3AvYECxnv6UpCGxUlRT9fVD+QJKu9JNWk8jIeR gbPranBTJZeDpGfQKJTW2VXTVA5eOJUspI2i2CLffSn7FT8HAZlbndIX4fmkT7aRh12c 2Vvx0doU1/VrpM4/5iVGbsMW5OQ4tvAxGZ7WWiVqS0mcjrixjvZzsgJWCeqZqJViclYO yW1zARTchHb2oR+YN2E7AwSFEolNBfnNlbfxhR7H1SFL+Y/srjy2qPV5HmcvAUBmiwuq WrDQ== MIME-Version: 1.0 Received: by 10.236.77.134 with SMTP id d6mr15909871yhe.79.1336414069344; Mon, 07 May 2012 11:07:49 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.147.55.41 with HTTP; Mon, 7 May 2012 11:07:49 -0700 (PDT) In-Reply-To: <4FA7C229.9080901@gmail.com> References: <4F847B8A.9010007@sugarcrm.com> <733bc8ea59cf6737563a62886e92fcb6.squirrel@www.l-i-e.com> <4FA7C229.9080901@gmail.com> Date: Tue, 8 May 2012 02:07:49 +0800 X-Google-Sender-Auth: SWOzKJnzmBxuQeYG4d5I16ZAkKI Message-ID: To: Hartmut Holzgraefe Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [off] PHP: a fractal of bad design From: datibbaw@php.net (Tjerk Anne Meesters) > On 05/07/2012 05:32 AM, Tjerk Anne Meesters wrote: > >> Validated or not, why would type juggling even come into the picture >> if both variables are of the same type? > > For the simple reason that web forms return all input as strings, even > if the input is actually meant to be numeric > > Many PHP database backend functions also return all result fields > as strings regardless of the actual result type, e.g. mysql_fetch_*(), > mysqli_fetch_*() and pg_fetch_*() =A0(although that's more debatable) Granted, I realized that my comment came across a bit too generic. What I meant to say is that the type juggling should be applied within its realm of usefulness and skipped otherwise lest it tell me "they're both pretty big numbers" :) I've always felt overly pedantic when I used =3D=3D=3D or strcmp() in strin= g comparisons (assuming the equality edge cases were not an issue; e.g. same string composition). > > So if both operands look numeric (even though they are actually of > type string) type juggling kicks, and in your MD5 example it > unfortunately kicks in with a conversion to float for both sides > and you're running into the "never compare floats for equality" > trap ... (which is being worked on for the string comparison case > though, i just don't have the bug number at hand right now) I'm assuming that you're referring to this bug reference: https://bugs.php.net/bug.php?id=3D54547 The proposed patch therein looks okay, though I'm not sure why the added test case is for 64bit systems only; seems to me that it can / should be run for other systems too.