This code, when entering the first if, will judge $ch+ $en + $ma >220, but $ch+ $en + $ma <220, the event stream will not jump out of this if, execute the later else?
60&&$ma>60&&$en>60){ if($ch+$en+$ma>220) {$tg='合格';};}else{$tg='不合格';}?>
Reply content:
This code, when entering the first if, will judge $ch+ $en + $ma >220, but $ch+ $en + $ma <220, the event stream will not jump out of this if, execute the later else?
60&&$ma>60&&$en>60){ if($ch+$en+$ma>220) {$tg='合格';};}else{$tg='不合格';}?>
1. The if...else between the same team is based on whether the conditions in the if are satisfied with the jump, different will not, even if the nested. So when a nested if condition in your if is not satisfied, it will look for any else that has it paired, and I'm sorry, there is no else associated with it, so $tag will be empty.
2. Note The writing format, the readability of the code, indentation, the position of the curly brace is immediately after the judgment condition, the operator must have a space on both sides.
60 && $ma > 60 && $en>60){ if($ch + $en+ $ma > 220){ $tg = '合格'; }else{ $tg = '不合格'; }}else{ $tg = '不合格';}?>
Of course, Xiayongsheng's style is more concise, but slightly more readable.
The next else is the first if Judge 60, if there is no else, that is, TG is empty
You can modify the following
= 220 && $ch >= 60 && $ma >= 60 && $en >= 60;$tg = $condition ? '及格' : '不及格';?>
if(明天下雨){ // 伞或雨衣 if(骑车) { // 雨衣 } } else { // 不带}
The rain is the premise of the raincoat.
If and else are paired (but else not required).
If at the outermost level corresponds to the outermost else, and so on.