Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60504 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76147 invoked from network); 7 May 2012 09:22:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2012 09:22:55 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:43857] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/06-33304-D6497AF4 for ; Mon, 07 May 2012 05:22:54 -0400 Received: by wgbfg15 with SMTP id fg15so3781515wgb.11 for ; Mon, 07 May 2012 02:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kjWXwgv+kxDLTW4qd+3vcNw4zQplc0qrsilLwZ3QbHQ=; b=Qno8sxk9wH6pNv7xv/A9u95K1gdkgEwd8YCwyA+aIaKHIV4Q1oB+PFOIQxd+OcwMHa 4iDv+qOOoIVE1dYVv+S9qyi5bvfzZ9p1HXlMcHkZCDH2O9JNi4HFbLTvxJDLHSkLDNIA z3vnBbdr4obWeWjNyPhzGThSTbntsBE/NaMl7LxAIyyVYj2K3pB/N4OZPMYf8IkhhPcG z4SYBa6M+CddcKzaj+ztf47N08FSEpGmpYWhxS0MnGugFwYMchkcFfVL8tHk2ONqykyN ClAnz5zSjhk6rUQ2BPu2QOAJ6xb0oC6Mvcd2CHeNE/c1e3z7yZ4e9oyOji4SpQNEyrWK crhA== MIME-Version: 1.0 Received: by 10.180.104.230 with SMTP id gh6mr33120898wib.22.1336382570107; Mon, 07 May 2012 02:22:50 -0700 (PDT) Received: by 10.223.96.129 with HTTP; Mon, 7 May 2012 02:22:50 -0700 (PDT) In-Reply-To: References: <4F847B8A.9010007@sugarcrm.com> <733bc8ea59cf6737563a62886e92fcb6.squirrel@www.l-i-e.com> Date: Mon, 7 May 2012 02:22:50 -0700 Message-ID: To: Gustavo Lopes Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d04428dca60138104bf6ed036 Subject: Re: [PHP-DEV] [off] PHP: a fractal of bad design From: kris.craig@gmail.com (Kris Craig) --f46d04428dca60138104bf6ed036 Content-Type: text/plain; charset=ISO-8859-1 On Mon, May 7, 2012 at 1:46 AM, Gustavo Lopes wrote: > On Mon, 07 May 2012 10:31:00 +0200, Kris Craig > wrote: > > That being said, I agree that this *definitely* should be fixed if the >> >> examples cited are indeed accurate (I've been working with PHP for over >> 10 years and I was never aware of this bizarre behavior, either). I don't >> know the history of this, but I at least would consider it to be a bug. >> A rather large one, in fact; though I think some of the fears expressed >> are a bit hyperbolic. And if you're fixing a serious bug or security >> vulnerability, as a general rule of thumb, this automatically supercedes >> any concerns regarding BC breakage IMHO. >> > > This has already been discussed in its own thread, see > http://comments.gmane.org/**gmane.comp.php.devel/72790; see also > https://bugs.php.net/bug.php?**id=54547 > > Doing away entirely with this behavior (e.g. making " 2" == "2" compare > false) would be a rather large BC break, that discussion is restricted to > whether integers in strings should be treated differently from integer > literals for comparison purposes when their range is exceeded. I wrote a > patch for that, and, while not really caring one way or the other, I'm not > convinced it's necessary and I some have consistency concerns (though float > overflows already get a similar treatment). > > -- > Gustavo Lopes > Agreed. While it's no secret that I believe optional strong typing would be helpful in this context, setting that aside I would definitely not want to see implicit conversions like "2" == 2 or even " 2" == 2 go away (though I do wish more PHP devs were familiar with the various trim() functions lol). That being said, this is what had me scratching my head from a previous message in this thread: >$a = "123ABF453..."; //a password >$b = "123DFEABC..."; //another one >if ($a == $b){ > //you're in. >} The thought that $a == $b would actually evaluate to TRUE is utterly absurd.... Only catch is, it doesn't. As I was sharpening my pitchfork getting ready to argue why this should be considered a bug and not conflated with implicit conversions like " 2" == 2, I decided to do a little test script against 5.3.11. I was unable to reproduce the behavior being reported in the above example. In my tests, $a == $b returned FALSE. As it should. @Richard Could you clarify what you were trying to illustrate with that code? I wasn't able to find anything wrong with how PHP handled it. So either you were mistaken or I misunderstood your point (if the latter, please tell me how so I can try again to repro the problem you're raising concern about). So with that in mind, the point I raised in the second paragraph of my last email is moot because I was referring to behavior that doesn't actually exist (again, unless I was testing for the wrong thing somehow?). Implicit conversions like " 1" == 1.0 I fully support so long as they can both be converted to numbers without loss of precision. --Kris --f46d04428dca60138104bf6ed036--