PHP Boolean Values like ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Micha

    PHP Boolean Values like ASP

    I'm traing to rewrite a part of code i've made in for ASP in PHP.

    ASP:
    If moneda = True Then
    moneda = False
    Else
    moneda = NOT moneda
    End If

    This change the value of the variable from true to false and the other
    way arround.

    My problem is that PHP asumes that Null value is also False value.
    So, I need three instances of the variable; when the variable was not
    already user, to asume the Null value. If the value is Null, then to
    change it to True, and when it is True to change it to false.
    How can I solve this PHP misunderstud between Null and False value?

    Thanks!
    ELMICHA
  • Phlarmf

    #2
    Re: PHP Boolean Values like ASP


    "Micha" <michaseba@tuto pia.com> wrote in message
    news:123e5db0.0 309150552.6163e 19e@posting.goo gle.com...[color=blue]
    > I'm traing to rewrite a part of code i've made in for ASP in PHP.
    >
    > ASP:
    > If moneda = True Then
    > moneda = False
    > Else
    > moneda = NOT moneda
    > End If
    >
    > This change the value of the variable from true to false and the other
    > way arround.
    >
    > My problem is that PHP asumes that Null value is also False value.
    > So, I need three instances of the variable; when the variable was not
    > already user, to asume the Null value. If the value is Null, then to
    > change it to True, and when it is True to change it to false.
    > How can I solve this PHP misunderstud between Null and False value?
    >
    > Thanks!
    > ELMICHA[/color]

    Try:

    if moneda === true
    moneda = false;
    else
    moneda = true;





    Comment

    • Phlarmf

      #3
      Re: PHP Boolean Values like ASP


      "Phlarmf" <no@email.com > wrote in message
      news:rSj9b.6014 $VS2.5155@pd7tw 1no...[color=blue]
      >
      > "Micha" <michaseba@tuto pia.com> wrote in message
      > news:123e5db0.0 309150552.6163e 19e@posting.goo gle.com...[color=green]
      > > I'm traing to rewrite a part of code i've made in for ASP in PHP.
      > >
      > > ASP:
      > > If moneda = True Then
      > > moneda = False
      > > Else
      > > moneda = NOT moneda
      > > End If
      > >
      > > This change the value of the variable from true to false and the other
      > > way arround.
      > >
      > > My problem is that PHP asumes that Null value is also False value.
      > > So, I need three instances of the variable; when the variable was not
      > > already user, to asume the Null value. If the value is Null, then to
      > > change it to True, and when it is True to change it to false.
      > > How can I solve this PHP misunderstud between Null and False value?
      > >
      > > Thanks!
      > > ELMICHA[/color]
      >
      > Try:
      >
      > if moneda === true
      > moneda = false;
      > else
      > moneda = true;
      >[/color]

      man... it's too early Monday... I forgot the braces on the if

      if (moneda === true)




      Comment

      • Dalibor Karlovic

        #4
        Re: PHP Boolean Values like ASP

        Micha wrote:
        [color=blue]
        > I'm traing to rewrite a part of code i've made in for ASP in PHP.
        >
        > ASP:
        > If moneda = True Then
        > moneda = False
        > Else
        > moneda = NOT moneda
        > End If
        >
        > This change the value of the variable from true to false and the other
        > way arround.[/color]

        $bMoneda = $bMoneda ? false : true;

        --
        Dado

        What this world needs is a good five-dollar plasma weapon.

        Comment

        • Alex Farran

          #5
          Re: PHP Boolean Values like ASP

          Micha writes:
          [color=blue]
          > How can I solve this PHP misunderstud between Null and False value?[/color]

          Do you know about the === and !== operators? They test for equality
          of both value and type. So the expression (false === null ) evaluates
          to false.

          --

          __o Alex Farran
          _`\<,_ Analyst / Programmer
          (_)/ (_) www.alexfarran.com

          Comment

          • Micha

            #6
            Re: PHP Boolean Values like ASP

            Alex Farran <alex@alexfarra n.com> wrote in message news:<m3n0d6rnn z.fsf@alexfarra n.com>...[color=blue]
            > Micha writes:
            >[color=green]
            > > How can I solve this PHP misunderstud between Null and False value?[/color]
            >
            > Do you know about the === and !== operators? They test for equality
            > of both value and type. So the expression (false === null ) evaluates
            > to false.[/color]

            It worked fine!!
            Thanks to all...

            Comment

            Working...