经测试代码如下:
/**
* 使用base HTTP验证
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function http_auth($un,$pw,$realm = "Secured Area")
{
if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_USER'] == $un && $_SERVER['PHP_AUTH_PW'] == $pw))
{
header('WWW-Authenticate: Basic realm="$realm"');
header('Status: 401 Unauthorized');
exit(); //???
}
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528896.html