這樣判斷對(duì)不對(duì)
<?php ????$totalMoney?=?0;//總工資 ????$basicMoney?=??300;//基本工資 ????$sex?=?"男"; ????$noHouse?=?TRUE;?//是否有房 ????$houseMoney?=??150;//住房補(bǔ)貼 ????$isPregnancy?=?TRUE;?//是否懷孕 ????$pregnancyMoney?=??100;//懷孕補(bǔ)貼 ??????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
2016-10-14
得到的答案是對(duì)的,因?yàn)樾詣e初始值已經(jīng)設(shè)定為男,你的判定條件?if($noHouse=true)又是有房,所以他沒用補(bǔ)貼,只能領(lǐng)基本工資300塊錢,遇到黑心老板了
2016-10-09
$sex == true ??
$noHouse ==true