f



if("0X0"=="000"){echo "boo";}

Hi ;)

Everything is in the title. the prob is "boo" is displayed ! Can you 
believe it ? Thanx for anyone who can help me.

fabrice.
0
3/11/2005 5:41:52 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

6 Replies
1188 Views

Similar Articles

[PageSpeed] 18

Fabrice R=E9gnier wrote:
> Hi ;)
>
> Everything is in the title. the prob is "boo" is displayed ! Can you
> believe it ? Thanx for anyone who can help me.
>
> fabrice.

That's because they are equal! PHP interprets the string "0X0" as zero
in Hexidecimal and that is equal to 0.

What are you trying to accomplish?

Ken

0
kenrbnsn (287)
3/11/2005 6:41:29 PM
Fabrice R?gnier <regnier.fab@free.fr> wrote:
> Everything is in the title. the prob is "boo" is displayed ! Can you 
> believe it ?

Yes, since that is exactly what to expect according to the == operators
specs

> Thanx for anyone who can help me.

The TFM will help which can be Read at:
http://nl2.php.net/manual/en/language.operators.comparison.php
http://nl2.php.net/manual/en/types.comparisons.php

0
spam206 (250)
3/11/2005 6:51:27 PM
On 11 Mar 2005 10:41:29 -0800, Ken Robinson wrote:
> What are you trying to accomplish?

Probably string comparison. Use strcmp().

-- 
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
0
3/11/2005 6:55:14 PM
Hi ;)

Thank you everybody, I used strcmp and everything is ok now.

 >What are you trying to accomplish?
Well, my strings full of "0" or "X" are results of analyses.

regards,

f.
0
3/11/2005 7:20:57 PM
*** Fabrice R�gnier escribi�/wrote (Fri, 11 Mar 2005 20:20:57 +0100):
> Well, my strings full of "0" or "X" are results of analyses.

Try === or strcmp() instead.


-- 
-+ �lvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buz�n
-+ Send your questions to the group, not to my mailbox
--
0
3/11/2005 9:55:57 PM
Fabrice R�gnier <regnier.fab@free.fr> wrote:
>
>Thank you everybody, I used strcmp and everything is ok now.

And do you understand why you got the result you got?  The "==" operator
will try to convert its operands to integers if it can.  "0X0" is a hex
constant that happens to evaluate to the integer 0.  "000" is a decimal
(arguably octal) constant that happens to evaluate to the integer 0.
Equal.
-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.
0
timr (1409)
3/12/2005 6:38:17 AM
Reply: