📄 20c04-1.php
字号:
<?php// Check if the server has provided us with a Valid User, and password:if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != 'MyUserName' || $_SERVER['PHP_AUTH_PW'] != 'MyPassWord' ) { // Username and Password did not match the ones we were looking for // Therefore send headers asking the client to authenticate. header('WWW-Authenticate: Basic realm="For Your Eyes Only"'); header('HTTP/1.0 401 Unauthorized'); // And give a generic output error message in case their client doesn't // understand Basic Authentication echo '<h1>401 Unauthorized!</h1><p>You cannot view this page</p>'; exit;}// If we made it this far, we can display a welcome message!// They successfully logged into our website.?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Authentication Test</title></head><body><h2>Hello <?= $_SERVER['PHP_AUTH_USER'] ?>:</h2><p>You entered <?= $_SERVER['PHP_AUTH_PW'] ?> as your password!</p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -