使用php预定义变量AUTH_类型处理基本身份验证
为什么在下面的脚本中,$\u服务器全局数组中没有AUTH\u TYPE的索引使用php预定义变量AUTH_类型处理基本身份验证,php,http-headers,basic-authentication,Php,Http Headers,Basic Authentication,为什么在下面的脚本中,$\u服务器全局数组中没有AUTH\u TYPE的索引 <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="hi please enter your password and username"'); header('HTTP/1.1 401 Unauthorized'); // this will show the log in b
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="hi please enter your password and username"');
header('HTTP/1.1 401 Unauthorized'); // this will show the log in box
echo 'Text to send if user hits Cancel button'; // this will show if the user click cancel
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
echo "<p> {$_SERVER['AUTH_TYPE']} your authentication type.</p>";
var_dump($_SERVER) ;
}
?>
我使用的是xampp包中的apache服务器AUTH_类型索引中应该有什么值?它应该是基本字符串吗?