Logic Operator

Discussion in 'PHP' started by chxxangie, Sep 18, 2007.

  1. #1
    if (a=1 AND b=1)

    if (a=1 && b=1)


    which one is correct?
    i search from internet, got both result....
     
    chxxangie, Sep 18, 2007 IP
  2. hemlata

    hemlata Peon

    Messages:
    18
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello chxxangie,

    First of all in your if conditions, you are not comparing variables 'a' and 'b' rather you are assigning them values as '1'. so the modified code will be..
    // compare just values OR
    if (a==1 AND b==1)
    if (a==1 && b==1)

    // compare value and type both
    if (a===1 AND b===1)
    if (a===1 && b===1)

    Both will give the same results.
     
    hemlata, Sep 18, 2007 IP