> 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 a
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 thi
On 10/4/09 6:36 AM, "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
>> might reasona
> 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 no
> $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 numb
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" 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
t;
>... 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 Vincent is surprised that:
>>
>> $num = 123;
>> $num = $num++;
>
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
t
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. Shoul
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
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 tru
Tom Worster wrote:
On 10/3/09 12:25 PM, "Ashley Sheridan" wrote:
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
On 10/3/09 7:21 AM, "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 wit
On 10/3/09 12:25 PM, "Ashley Sheridan" wrote:
> On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
>
>> On 10/3/09 7:21 AM, "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
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 why
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote:
> On 10/3/09 7:21 AM, "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
On 10/3/09 7:21 AM, "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 ($names); while ($
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 seco
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
Daevid Vincent is surprised that:
$num = 123;
$num = $num++;
print $num; //this prints 123 and not 124 ?!!
To me this is relatively logical. As I understand it, the post-increment
operator says "do
something with the variable, and then increment it. The trouble in this case is
that we
are doin
19 matches
Mail list logo