返回首页
当前位置: 首页>Lamp教程>PHP>

学习掌握动态网页PHP的编程语句(2)

时间:2008-11-19 14:40来源: 作者: 点击:
while (condition) { statements; } 一个空的while语句应该具有如下格式: while (condition); 7 do...while语句 一个do-while语句应该具有如下格式: 以下为引用的内容: d
  

while (condition) {
  statements;
}

一个空的while语句应该具有如下格式:

while (condition);

7 do...while语句

一个do-while语句应该具有如下格式:

以下为引用的内容:

do {
  statements;
} while (condition);

8 switch语句

一个switch语句应该具有如下格式:

以下为引用的内容:

switch (condition) {
  case ABC:
  /* falls through */
    statements;
  case DEF:
   statements;
   break;
  case XYZ:
    statements;
    break;
  default:
    statements;
    break;
}

每当一个case顺着往下执行时(因为没有break语句),通常应在break语句的位置添加注释。上面的示例代码中就包含注释/* falls through */。

9 try...catch语句

一个try-catch语句应该具有如下格式:

try {
  statements;
} catch (ExceptionClass e) {
  statements;
}

一个try-catch语句后面也可能跟着一个finally语句,不论try代码块是否顺利执行完,它都会被执行。

以下为引用的内容:

try {
  statements;
} catch (ExceptionClass e) {
  statements;
} finally {
  statements;
}

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
Google
推荐内容