 
		慕慕2218550
2017-12-28 17:01
<?php
    $totalMoney = 0;//总工资
    $basicMoney =  2000;//基本工资
    $month=0;
 $sex = "女";
  if($sex=="男"){
  $totalMoney = $basicMoney  + 0;// 男的没奖金
     }else if(date('m',time()=='11') and $sex=="女")
     {
  $totalMoney = $basicMoney  + 300;// 女的有奖金300元
  $month=date('m',time());
     }
 echo $totalMoney;
 echo $month;
?>
为什么还是输出2300?
 
				你可以查一下php的date()这个方法,我查了一下,date() 函数格式化本地日期和时间,并返回已格式化的日期字符串。应该是这样用,else if(date('m',time()) == '11' and $sex == “女"),可能是你要的结果。http://www.w3school.com.cn/php/func_date_date.asp
 
				括号位置问题 第二个elseif你仔细看下
 
				朋友这个只是你判断语句写错了 else if(date('m',time()=='11') and $sex=="女") 改成
else if(date('m',time())=='11' and $sex=="女")
 
				设置了第二个IF语句,else if(date('m',time()=='11') and $sex=="女")
两个条件要都成立,才执行累加,为什么当前月份是12月,也会执行呢?
 
				.....
PHP入门篇
456546 学习 · 6590 问题
相似问题