<?phpheader("Content-Type:text/html;charset=utf-8");function alert_herf($text){echo'<script language="javascript">alert("'.$text.'");top.location='."'"."./login.html?a=login"."'".';</script>';}$type=$_GET['a'];switch ($type) {//当变量$type的是login的时候执行,login下的内容,如果是login_api就执行login_api下的分支语句case 'login':include("./tamplate/login.html");break;case 'login_api':$username=$_POST['username'];$password=$_POST['password'];if (empty($username)) {// code...alert_herf("请输入用户名,再提交");}if(empty($password)){alert_herf("请输入密码,再提交");}if ($username == "admin" && $password == "123456") {$text= "登陆成功";alert_herf($text);}else {$text= "登陆失败";alert_herf($text);}default:// code...break;}?>
switch作为分支机构语句进行php的代码当中
