Home >php教程 >php手册 >PHP 编码规范(16)

PHP 编码规范(16)

WBOY
WBOYOriginal
2016-06-13 10:20:45916browse

6.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 */。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP 编码规范(5)Next article:PHP 编码规范(6)