标签:
1、if语句分为三种情况:
单分支
if(条件){}
双分支
if(条件){} else{}
多分支
if(条件){} elseif(条件){} elseif(条件){} ...else{}
2、switch语句
格式:
switch(表达式){ case 值1: 语句1; break; case 值2: 语句2; break; ... default: 语句n; break; }
例子:
<?php $weekday = date(‘N‘); //echo $weekday; //多分支结构 if($weekday == 1){ echo "周一"; }elseif ($weekday == 2) { echo "周二"; }elseif($weekday ==3){ echo "周三"; }else{ echo "其他"; } //switch语句 switch ($weekday) { case ‘1‘: echo "周一"; break; case ‘2‘: echo "周二"; break; case ‘3‘: echo "周三"; break; default: echo "其他"; break; } ?>
标签:
原文地址:http://www.cnblogs.com/chinas/p/4841871.html