Home > Article > Backend Development > How to write student grade level in if statement in php
How to write the student performance grade in the if statement in php?
The code is as follows:
php语言 var $score;//分数变量 if($score<60){ echo "不及格"; }elseif($score<69 && $score>=60){ echo "及格"; }else if($score>=70 && $score<80){ echo "中"; }else if($score>=80 && $score<90){ echo "良"; }else{ echo "优"; }
Extended information:
if statement:
if statement refers to programming language (including C language, C, C#, java, VB, assembly language, etc.) is used to determine whether a given condition is met, and one of the two operations given is executed based on the result of the determination (true or false). The return value of if is true or false, which can be stored in a bool variable and occupies one byte.
General form of if statement:
if (expression) statement 1
else statement 2
The "expression" in the if statement can be a relational expression, a logical expression, or even a numerical expression. Among them, the most intuitive and easiest to understand are relational expressions. The so-called relational expression is an expression that compares two numerical values.
Recommended tutorial: "php tutorial"
The above is the detailed content of How to write student grade level in if statement in php. For more information, please follow other related articles on the PHP Chinese website!