慕粉4098010
2016-10-03 15:00
怎么在生日 和 普通折扣中最大
上面的代码太多了吧
//你的问题要用switch语句,还没学,代码和图示如下: <?php header("Content-type: text/html; charset=utf-8"); date_default_timezone_set('Asia/ShangHai'); $today = date('m-d',time());//获取当天日期 $birthday = "02-14";//生日 $money=2000; $discount; switch($money){ case($money>=1500): //满1500以上的75折 $discount=0.75; break; case($today==$birthday): //今天生日8折 $discount=0.8; break; case($money>=500): //满500不满1500的95折 $discount=0.95; break; default: $discount=1; break; } $money=$money*$discount; echo $money; ?>
.123313
<?php date_default_timezone_set('Asia/ShangHai'); $today = date('m-d',time());//获取当天日期 $birthday = "02-14";//生日 $money=2000; $discount; if($today==$birthday) //今天生日8折 { $discount=0.8; } if($money>=500&&$money<1500) //满500不满1500的95折 { $discount=0.95; } if($money>=1500) //满1500以上的75折 { $discount=0.75; } else //其他的均不打折 { $discount=1; } $money=$money*$discount; echo $money; ?>
生日那天,满1500
PHP入门篇
456326 学习 · 6575 问题
相似问题