1<!doctype html>2<meta http-equiv= "Content-type" content= "text/html" charset= "Utf-8"/>3Switch statement, the switch statement is used to perform different actions based on several different conditions. <br/>4 If you want to selectively execute one of several blocks of code, also use a switch statement. 5<br/>6 The syntax structure is as follows:7<pre>8 Switch(n)9 {Ten CaseLabel1: Onesuch as n=Label1, here the code will be executed; A Break; - CaseLabel2: -such as n=Label2, here the code will be executed; the Break; - CaseLABEL3: -such as n=Label3, here the code will be executed; - Break; + default: - if n does not equal the Label1 page is not equal to Label2, the code here will execute; + } A</pre> at - We write a program, a radio box. Use the switch statement half paragraph. -<br/> - The procedure is as follows: -<br/> -<form method= "Get" action= "<?php Echo$_server[' php_self '];? > "> inRed: <input type= "Radio" name= "Color" value= "1"/><br/> -Blue: <input type= "Radio" name= "Color" value= "2"/><br/> toGreen: <input type= "Radio" name= "Color" value= "3"/><br/> +<input type= "Submit"/> -</form> the<?PHP * if(!Empty($_get[' Color '])){ $ Switch($_get[' Color '])Panax Notoginseng { - Case1: the Echo"Your choice is red!" "; + Break; A Case2: the Echo"You chose the blue!" "; + Break; - Case3: $ Echo"Your choice is green!" "; $ Break; - default: - Echo"You have not chosen any one color!" "; the } - }Wuyi?>
Code Case
Submit data from the form, accept and submit it by get, and then use empty to determine if the accepted data is empty. Then perform the If judgment to execute the switch statement, you can do a multi-select operation!
Use the switch statement to judge multiple choices.