Re: [off] PHP: a fractal of bad design

From: Date: Mon, 07 May 2012 12:23:54 +0000
Subject: Re: [off] PHP: a fractal of bad design
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 05/07/2012 09:28 AM, Arvids Godjuks wrote:
> Hello internals,
> 
> I should voice my opinion that such things like comparing two strings
> starting with numbers and that they resolve to actual integer/float for
> comparation is bad, really bad. That just defies the logic and yealds
> absolutly unexpected results. I pride myself that i know the juggling rules
> well, but I'm shocked by this to say the least..

you have to see this in the "web context" where all input from a
HTTP client arrives as strings without type information (and some
database result data comes in as string data, too)

In that context it perfectly makes sense that

  "1" == "1.0"

returns true even if both operands are strings.

"123ABF453..." == "123DFEABC..." is a different story though,
and guess what? These are *not* considered equal, at least not
by the 5.3.6 instance on the system i'm currently testing with:

  <?php
  $a = "123ABF453..."; //a password
  $b = "123DFEABC..."; //another one
  if ($a == $b){
    echo "you're in";
  } else {
    echo "no, you don't get in *that* easy!";
  }
  ?>

will print "no, you don't get in *that* easy!" just fine

-- 
hartmut


Thread (42 messages)

« previous php.internals (#60508) next »