PHP - Multiple conditions for if statement

时间:2015-06-25 18:28:30

标签: php

I have two if statements which look something like this:

    //check if submit button is clicked and if the item is not expired
    if(isset($_POST['submit_bid']) && time() < strtotime($itemData[0]['exp_date']) ) 
    {
        //check if bid is lower than max bid or lower than start bid
        //if there is no bid $itemData[0]['max_bid'] is empty, should I check for that too?
        if($_POST['buy_bid'] <= $itemData[0]['max_bid'] || $_POST['buy_bid'] <= $itemData[0]['item_start']) 
        {
         //do stuff
        }else{
         //do stuff
        }

    }else{
     //do stuff
    }

I want to know if there is anything wrong with having 4, 5 or more conditions in the first if. I don't think the way I have it set up is right.

1 个答案:

答案 0 :(得分:0)

do you mean something like this?

 //check if submit button is clicked and if the item is not expired
 if((isset($_POST['submit_bid']) && time() < strtotime($itemData[0]['exp_date'])) || ($_POST['buy_bid'] <= $itemData[0]['max_bid'] || $_POST['buy_bid'] <= $itemData[0]['item_start']) ) 
 {
   // do stuff
 }