473,224 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

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.
Jul 17 '05 #1
6 2431

Fabrice Régnier 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

Jul 17 '05 #2
Fabrice R?gnier <re*********@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/languag...comparison.php
http://nl2.php.net/manual/en/types.comparisons.php

Jul 17 '05 #3
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/
Jul 17 '05 #4
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.
Jul 17 '05 #5
*** 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
--
Jul 17 '05 #6
Fabrice Régnier <re*********@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, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.