Conditional statements for beginners to PHP

if Judgment statement

Format: if (condition){

Execution code

}

if...else Statement

Format if (condition){

Code block 1;

}else{

Code Block 2;

}

Note: Give a variable and assign a value equal to 0 Determine whether $i is equal to 1 If equal, output the first echo statement, otherwise output the second echo statement

if...else if...else


Format: if (condition 1){

Code block 1;

}else if(condition 2){

Code block 2;

}else{

Code block 3;

}

=60 and $a<80){ echo "良好"; }else if($a>=80 and $a<90){ echo "非常好"; }else{ echo "优秀"; } ?>


##switch statement


Format:

$a = 2;

switch($a){

case 1: Execute code 1; break;

case 2: execute code 2; break;

case 3: execute code 3; break;

case 4: execute code 4; break;

default: execute code;

}


break jump

In switch, when the break statement is encountered, Instead of executing downward, realize the jump



##

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!