PHP首部认证
Posted ZooJinGoo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP首部认证相关的知识,希望对你有一定的参考价值。
PHP首部认证
<?php
// User name and password for authentication
$username = 'rock';
$password = 'roll';
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
($_SERVER['PHP_AUTH_USER'] != $username) || ($_SERVER['PHP_AUTH_PW'] != $password))
// The user name/password are incorrect so send the authentication headers
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Guitar Wars"');
exit('<h2>Guitar Wars</h2>Sorry, you must enter a valid user name and password to access this page.');
?>
以上是关于PHP首部认证的主要内容,如果未能解决你的问题,请参考以下文章