1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Multiple conditions in if statement

Discussion in 'PHP' started by egdcltd, Nov 9, 2006.

  1. #1
    How do I write an if statement with multiple conditions needing to be true?

    ie:

    if (condition1=a AND condition2=b AND condition3=c)
    {
    }
    else
    {
    }

    I'm sure it can be done, I just can't find instructions on how to do it.
     
    egdcltd, Nov 9, 2006 IP
  2. KC TAN

    KC TAN Well-Known Member

    Messages:
    4,794
    Likes Received:
    353
    Best Answers:
    0
    Trophy Points:
    155
    #2
    
    if ($x=='x' && $y=='y' && $z=='z'){
    // do if matches
    }else {
    //do otherwise
    }
    
    PHP:
    Hope that this is what you want :)
     
    KC TAN, Nov 9, 2006 IP
    kamleshnishad and egdcltd like this.
  3. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, that was exactly what I was looking for. Thanks.
     
    egdcltd, Nov 10, 2006 IP
  4. psingh55

    psingh55 Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    if (condition1 && condition2 && condition3){
    //if all condition are true then if block will executive
    }else {
    //do otherwise
    }

    or
    if (condition1 || condition2 || condition3 ||condition4 ){
    //any one condition are true then if block will executive
    }else {
    //do otherwise
    }

    Reference
    http://tutorialsflow.com
     
    psingh55, Jul 7, 2016 IP