Re: Strange 'if' test bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



strange question: I'm trying to figure out how to build a dating website? Anyone have any off the cuff advice for me...

I know next to nothing about PHP, and am desperately trying to teach myself.

-Yigal


From: "Christian Zambrano" <czambran@xxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Subject: Re:  Strange 'if' test bug?
Date: Wed, 1 Sep 2004 10:07:06 -0500

I think PHP converts to whatever type is on the left of the equal sign which
will make a lot of sense to me. I haven't thoroughly tested it.


Christian
----- Original Message -----
From: "Charles P. Killmer" <charlesk@xxxxxxxxxxxxxxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Tuesday, August 31, 2004 11:03 AM
Subject: RE:  Strange 'if' test bug?


> 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@xxxxxxx] > Sent: Tuesday, August 31, 2004 10:35 AM > To: php-windows@xxxxxxxxxxxxx > Subject: Re: 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 > >

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


_________________________________________________________________
Designer Mail isn't just fun to send, it's fun to receive. Use special stationery, fonts and colors. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.


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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux