亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Conditional statements for beginners to PHP

if Judgment statement

Format: if (condition){

Execution code

}

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼
	$a = 15;
	if($a==15){
		echo "滿足條件";
	}
	
	//注:條件判斷的時(shí)候,不要寫一個(gè)等號  一個(gè)等號是賦值
?>

if...else Statement

Format if (condition){

Code block 1;

}else{

Code Block 2;

}

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼
	//if....else
	//1代表 北京   0代表上海
	$i=0;

	if($i==1){
		echo "歡迎來到北京";
	}else{
		echo "歡迎來到上海";
	}
?>

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;

}

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼
	//判斷一個(gè)人的考試成績
	//60以下不及格
	//70-80之間良好
	//80-90之間非很好
	//90-100之間優(yōu)秀

	$a = 90;
	if($a<60){
		echo "不及格";
	}else if($a>=60 and $a<80){
		echo "良好";
	}else if($a>=80 and $a<90){
		echo "非常好";
	}else{
		echo "優(yōu)秀";
	}
?>


##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;

}

<?php
header("Content-type: text/html; charset=utf-8");//設(shè)置編碼
//判斷一個(gè)人是年紀(jì)大小的狀況

$a = 50;
switch ($a) {
	case 20:echo "少年";break;
	case 30:echo "青年";break;
	case 40:echo "中年";break;
	case 50:echo "中老年";break;
	default:echo "老年";
}

?>


break jump

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



##

Continuing Learning
||
<?php header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 $a = 15; if($a==15){ echo "滿足條件"; } ?>
submitReset Code