通过超级变量达到页面登录验证
$authorization = false; $user = $_SERVER['PHP_AUTH_USER']; $users = [ 'admin123' => 'admin']; if(in_array($user, $users) && $_SERVER['PHP_AUTH_PW'] == array_search($user, $users)){ $authorization = true; } if(!$authorization){ header("WWW-Authenticate:Basic realm='Private'"); header('HTTP/1.0 401 Unauthorized'); print "You are unauthorized to enter this area."; }