商讯信箱
用户名: @
密  码:   注册|忘记密码
登录
个人用户经销商
您的位置:首页 > 技术频道 > 正文

入门:学习掌握PHP的编程语句

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;
}
1 2 3 4
【内容导航】
第1页: 简单的语句 第2页: if与else语句
第3页: for语句 第4页: switch语句
©版权所有。未经许可,不得转载。
[责任编辑:阿雪]
[an error occurred while processing this directive]