but is implicitly converted into strings when it is entered.
use floatVal($str1) === floatVal($str2) then ... I honestly cannot spot any
problem in what you wanna do, I can just spot an error in the root of the
process: threat strings as numbers, comparing potatoes and tomatoes ...
there
On Sun, 4 Oct 2009 14:52:36 +0200, an_...@hotmail.com (Andrea Giammarchi) wrote:
$a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0;
$a==$b==$c==$d,
and
$b===$c===$d
$b , $c, and $d are the same indeed ... they represent the floating point
2260.0 in I think every language
I am well aware of the === operator, but I had an uneasy feeling that there was
still a
trap. However when I tried it it worked, so I was going to thank you for your
suggestion,
though I find the concept of having separate 'sort of equal' and 'truly equal'
operators
decidedly distasteful, but
On Sat, 03 Oct 2009 11:57:36 -0400, f...@thefsb.org (Tom Worster) wrote:
On 10/3/09 7:21 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
However there is one feature of PHP which, to my mind, is really bad design.
How many of
you can see anything wrong with the following procedure to
$a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0;
$a==$b==$c==$d,
and
$b===$c===$d
$b , $c, and $d are the same indeed ... they represent the floating point
2260.0 in I think every language ... it's like saying that 1.0 is not 1.
... both floating point numbers,
All very messy!
there is nothing messy, the logic is well defined and for a loose type language
it's absolutely normal behavior.
Regards
_
Keep your friends updated—even when you’re
On 10/4/09 6:36 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
i might think it ok for (2260 == '226E1') to be true since php would be
doing type juggling in a logical left-to-right manner: we start with an
integer 2260, next is the juggling comparison operator, then a string, so it
And then you discover ===
$i = 0; $j = count ($names); while ($i $j)
{ if ($names[$i] === $target) { break; }
++$i;
}
... regards
To: php-general@lists.php.net
From: clanc...@cybec.com.au
Date: Sat, 3 Oct 2009 21:21:00 +1000
Subject: [PHP] A really wacky design decision
Daevid
At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote:
Daevid Vincent is surprised that:
$num = 123;
$num = $num++;
print $num; //this prints 123 and not 124 ?!!
I can understand why someone might think this is not correct, but
they need to understand what is happening and why the above
On 10/3/09 7:21 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
However there is one feature of PHP which, to my mind, is really bad design.
How many of
you can see anything wrong with the following procedure to search a list of
names for a
particular name?
$i = 0; $j = count
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
On 10/3/09 7:21 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
However there is one feature of PHP which, to my mind, is really bad design.
How many of
you can see anything wrong with the following procedure to search a list
tedd wrote:
At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote:
Daevid Vincent is surprised that:
$num = 123;
$num = $num++;
print $num; //this prints 123 and not 124 ?!!
I can understand why someone might think this is not correct, but
they need to understand what is happening and
On 10/3/09 12:25 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
On 10/3/09 7:21 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
However there is one feature of PHP which, to my mind, is really bad design.
How many of
you
Tom Worster wrote:
On 10/3/09 12:25 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
On 10/3/09 7:21 AM, clanc...@cybec.com.au clanc...@cybec.com.au wrote:
However there is one feature of PHP which, to my mind, is really bad design.
if we compare via == there is an implicit cast to the most primitive form.
These are all true, and all have a reason, and make sense:
// (int)'abc' is 0
var_dump('abc' == 0);
// 'abc' is not an empty string
var_dump('abc' == true);
// 2 is not 0, which would be casted into false, so it's true
Andrea Giammarchi wrote:
If you use APD or you think about the low level logic behind comparing string,
num and bool you'll probably forget the == operator and you'll
never miss
again the === one ... then you'll start to explicit cast
everything, when
necessary, to have all your code truly
You introduced the word suddenly, it's about 10 years I develop in PHP
Regards
PHP allows you to do either. If I find myself being more strict in no
way does that mean I'll suddenly jump to another language. It just means
I have a bit of code that requires a bit more strictness. Should I
At 1:37 PM -0400 10/3/09, Robert Cummings wrote:
tedd wrote:
At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote:
Daevid Vincent is surprised that:
$num = 123;
$num = $num++;
print $num; //this prints 123 and not 124 ?!!
I can understand why someone might think this is not correct, but
18 matches
Mail list logo