在一个if语句中进行多次检查的语法


PHP Syntax for multiple checks in one if statement

我正在为一个项目制作一个shoppingcart.php文件,该文件由同一项目中的另一个名为"catalog.php"的文件提供信息。我所坚持的事情是一个while循环内的if语句(它应该通过从catalog.php传入的表单数据循环)。由于某些原因,它不像这样:

//Loop through each form field (this page is called from catalog.php):        
    //If form field’s value (product quantity) is a positive number
//(nonzero), is NOT the submit button, AND the remove checkbox for 
//removing this product has NOT been checked (do these checks in one
    //condition):        
    while (list($productID,$qty) = each($_POST)){
        if(($qty > 0) && (type != submit) && (checkbox != isset())){
        }            
    }

我的if语句有什么问题?

您使用php的isset()不正确。isset()需要一个变量参数和"[决定]是否设置了一个变量并且不为NULL"。

试试这个:

if (($qty > 0) && ($type != 'submit') && !isset($checkbox)) {
}