date_default_timezone_set('Asia/ShangHai'); $today = date('m-d',time());//获取当天日期 $birthday = "02-14";//生日 $money = 238;//消费金额 $discount = 0.8;//八折优惠 if($today && $birthday){ $money = $money*$discount; }else{ $money = $money * 1; } echo $money; 为什么这样不对啊 它老是执行esle ????我把==换成了逻辑与&&,这样不可以吗?
你生日的日期没修改吧
date_default_timezone_set('Asia/ShangHai'); $today = date('m-d',time());//获取当天日期 $birthday = "02-14";//生日 $money = 238;//消费金额 $discount = 0.8;//八折优惠 if($today && $birthday){ $money = $money*$discount; }else{ $money = $money * 1; } echo $money;