Home > php教程 > PHP开发 > Example code for using switch statement to make multiple selections

Example code for using switch statement to make multiple selections

高洛峰
Release: 2016-12-26 10:54:51
Original
1554 people have browsed it

The examples are as follows:

<!doctype html>
<meta http-equiv="content-type" content="text/html" charset="utf-8"/>
switch语句,switch语句用于根据多个不同条件执行不同动作。<br/>
如果你希望有选择地执行若干代码块之一,还请使用switch语句。
<br/>
语法结构如下:
<pre class="brush:php;toolbar:false">
switch(n)
{
case label1:
  如n=label1,此处代码将执行;
  break;
case label2:
  如n=label2,此处代码将执行;
  break;
case label3:
  如n=label3,此处代码将执行;
  break;
default:
  如果n既不等于label1页不等于label2,此处代码将执行;
}

我们写一个程序,一个单选框。用switch语句半段。
程序如下:
红色:
蓝色:
绿色:
Copy after login

The above is the entire content of the example code that the editor brought to you for using the switch statement to make multiple selections. I hope Please support the PHP Chinese website~

For more relevant articles on example codes that use switch statements to perform multiple selections, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template