PHP 헤더 인증
<code><span><span><?php</span><span>// User name and password for authentication</span><span>$username</span> = <span>'rock'</span>; <span>$password</span> = <span>'roll'</span>; <span>if</span> (!<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>]) || !<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>]) || (<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>] != <span>$username</span>) || (<span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>] != <span>$password</span>)) { <span>// The user name/password are incorrect so send the authentication headers</span> header(<span>'HTTP/1.1 401 Unauthorized'</span>); header(<span>'WWW-Authenticate: Basic realm="Guitar Wars"'</span>); <span>exit</span>(<span>'<h2>Guitar Wars</h2>Sorry, you must enter a valid user name and password to access this page.'</span>); } <span>?></span></span></code>
이상 내용의 측면을 포함해 첫 번째 PHP 자격증을 소개했습니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.