本文的copyright归yuweixian4230@163.com 所有,使用GPL发布,可以自由拷贝,转载。
但转载请保持文档的完整性,注明原作者及原链接,严禁用于任何商业用途。
作者:yuweixian4230@163.com
博客:yuweixian4230.blog.chinaunix.net
控制结构
1.条件语句 if elseif else switch
2.循环语句 while for foreach
if elseif else
- $secretNumber = 453;
-
if($_POST['guess'] == $secretNumber)
-
{
-
echo "
Congratulation!
";
-
}
-
elseif($_POST['guess' == 412])
-
{
-
echo "xx";
-
}
-
else
-
{
-
echo "
sorry !!
";
-
}
switch
- $category = "news";
-
switch($category)
-
{
-
case "news":
-
echo "hello news
";
-
break;
-
case "sports":
-
echo "hello sports
";
-
break;
-
default:
-
echo "welocome to my web site";
-
}
while for
- $count = 1;
-
while($count < 5)
-
{
-
printf("%d squard is %d
",$count,pow($count,2));
-
$count++;
-
}
-
-
echo "
";
-
-
$count = 1;
-
for($count=1;$count < 5; $count++)
-
{
-
printf("%d squard is %d
",$count,pow($count,2));
-
}
foreach
- $links = array("","");
-
echo "online resources
";
-
foreach($links as $link)
-
{
-
echo "link is $link
";
-
}
- online resources
-
link is www.chinaunix.net
-
link is www.csdn.net
阅读(741) | 评论(0) | 转发(0) |