1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title></title> 5 <meta charset="utf-8"> 6 </head> 7 <body> 8 <form action="" method="get"> 9 <select name="select_option"> //html语法:<select><option></option></select> 10 <option value = "" > Please select a city </ the Option > // default display for the first: Please select a city 11 < the Option value = "Beijing" > Beijing </ the Option > 12 < the Option value = "Shanghai" > Shanghai </ the Option > 13 < the Option value = "Guangzhou" > Guangzhou </ the Option > 14 < the Option value = "Shenzhen" > Shenzhen </ the Option > 15 <option value="大连">大连</option> 16 </select> 17 <input type="submit" value="点击"> 18 </form> 19 <?php 20 header("Content-Type:text/html;charset=utf-8"); 21 $selected=isset($_GET["select_option"])?$_GET["select_option"]:"";
Determine whether a variable is set and not nullisset - //
Expression Condition 1:? The second condition
If the expression is true returns 1 conditions, if it is false returns for 2.
isset () function
isset function variables used to determine whether or not there.
$action=isset($_GET['id']) ? $_GET['id'] : '';
What this means is that: if $ _GET [ 'id'] has been set, i.e., already has a value, then the $ _GET [ 'id'] $ Action assigned;
If $ _GET [ 'id'] is not set, then $ action = '';
22 echo $selected;
23 ?>
24
25 </body>
26 </html>
show result: