Basic HTTP 认证范例
HI {$_SERVER['PHP_AUTH_USER']}."; echo "恭喜你登录成功!
"; }else{ header('WWW-Authenticate: Basic realm="test"'); header('HTTP/1.0 401 Unauthorized'); } }?>
Digest HTTP 认证范例
1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); $data = array(); preg_match_all('@(\w+)=([\'"]?)([a-zA-Z0-9=./\_-]+)\2@', $txt, $matches, PREG_SET_ORDER); //print_r($matches); foreach ($matches as $m) { $data[$m[1]] = $m[3]; unset($needed_parts[$m[1]]); } return $needed_parts ? false : $data;}?>