[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-windows
Subject:    RE: [PHP-WIN] Strange 'if' test bug?
From:       "Charles P. Killmer" <charlesk () netgaintechnology ! com>
Date:       2004-08-31 16:03:16
Message-ID: B141BE87473AA64FB24370C43CEA54BD0116879E () ngexbe1 ! my-netgain ! com
[Download RAW message or body]

I would think that PHP should make the conversion in the other direction
to avoid losing data.  In other words, if a conversion is necessary,
convert to the data type that can handle the greater variety of data.
In this case to strings.  It would probably always be to strings though.

Charles 

-----Original Message-----
From: Christian Zambrano [mailto:czambran@mum.edu] 
Sent: Tuesday, August 31, 2004 10:35 AM
To: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Strange 'if' test bug?

$key=0;
$key=="muppet"?TRUE:FALSE;
The reason this last comparison returns true is that since you are
comparing an integer with a string, the strings gets converted to an
integer and since "muppet" does not have any numeric character it gets
converted to 0. In other words as far PHP in concerned you are comparing
0 with 0 which is why the result of comparison is a true statement.

Any thoughts on this?

Thanks
Christian

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic