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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabrice Régnier

    #1

    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.
  • Ken Robinson

    #2
    Re: if("0X0&qu ot;=="000& quot;){echo "boo" ;}


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

    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

    Comment

    • Daniel Tryba

      #3
      Re: if("0X0&qu ot;=="000& quot;){echo "boo" ;}

      Fabrice R?gnier <regnier.fab@fr ee.fr> wrote:[color=blue]
      > Everything is in the title. the prob is "boo" is displayed ! Can you
      > believe it ?[/color]

      Yes, since that is exactly what to expect according to the == operators
      specs
      [color=blue]
      > Thanx for anyone who can help me.[/color]

      The TFM will help which can be Read at:



      Comment

      • Ewoud Dronkert

        #4
        Re: if(&quot;0X0&qu ot;==&quot;000& quot;){echo &quot;boo&quot; ;}

        On 11 Mar 2005 10:41:29 -0800, Ken Robinson wrote:[color=blue]
        > What are you trying to accomplish?[/color]

        Probably string comparison. Use strcmp().

        --
        Firefox Web Browser - Rediscover the web - http://getffox.com/
        Thunderbird E-mail and Newsgroups - http://gettbird.com/

        Comment

        • Fabrice Régnier

          #5
          Re: if(&quot;0X0&qu ot;==&quot;000& quot;){echo &quot;boo&quot; ;}

          Hi ;)

          Thank you everybody, I used strcmp and everything is ok now.
          [color=blue]
          >What are you trying to accomplish?[/color]
          Well, my strings full of "0" or "X" are results of analyses.

          regards,

          f.

          Comment

          • Alvaro G. Vicario

            #6
            Re: if(&quot;0X0&qu ot;==&quot;000& quot;){echo &quot;boo&quot; ;}

            *** Fabrice Régnier escribió/wrote (Fri, 11 Mar 2005 20:20:57 +0100):[color=blue]
            > Well, my strings full of "0" or "X" are results of analyses.[/color]

            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
            --

            Comment

            • Tim Roberts

              #7
              Re: if(&quot;0X0&qu ot;==&quot;000& quot;){echo &quot;boo&quot; ;}

              Fabrice Régnier <regnier.fab@fr ee.fr> wrote:[color=blue]
              >
              >Thank you everybody, I used strcmp and everything is ok now.[/color]

              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.

              Comment

              Working...