<?php $totalMoney = 0;//总工资 $basicMoney = 300;//基本工资 $sex = "男"; $noHouse = TRUE; //是否有房 $houseMoney = 150;//住房补贴 $isPregnancy = TRUE; //是否怀孕 $pregnancyMoney = 100;//怀孕补贴 if($sex=="男"){ if($noHouse=true){ $toalMoney= $basicMoney; } else{ $toalMoney= $basicMoney+ $houseMoney; } } else if($sex=='女'){ if($isPregnancy=true){ $toalMoney=$basicMoney+$pregnancyMoney ; } else{ $toalMoney=$basicMone; } } echo $toalMoney; ?>
得到的是300
得到的答案是对的,因为性别初始值已经设定为男,你的判定条件 if($noHouse=true)又是有房,所以他没用补贴,只能领基本工资300块钱,遇到黑心老板了
$sex == true
$noHouse ==true