我有代码
<?php
$pickuptime = date("H",strtotime($_COOKIE['stm_calc_pickup_date_1'] ));
if($pickuptime > 9 && $pickuptime < 20 ) {
$nonworking_pick = 0;
} else {
$nonworking_pick = 10;
}
$returntime = date("H",strtotime($_COOKIE['stm_calc_return_date_1'] ));
if($returntime > 9 && $returntime < 20 ) {
$nonworking_return = 0;
} else {
$nonworking_return = 10;
}
$total_non_working = $nonworking_return + $nonworking_pick;
;
?>
它说如果接机时间是从9到20,则给0否则为10,同样要返回,但是如果没有选择接机时间和返回时间也要给0,我还需要添加选项。请帮助我:(
答案 0 :(得分:0)
尝试类似的东西:
if(!$pickuptime && !$returntime){ $nonworking_pick = 0; }
!表示“不是”。因此,“如果不是$ pickuptime而不是$ returntime。”
“不”表示“不正确”。如果变量为空白或零,则它们将为“ not true”。
更新:
如果您的“未选中”值不是空白或零,则可能需要使用!以外的其他内容。