要獲取PHP用戶信息,您可以使用$_SERVER
全局變量
$username = $_SERVER['PHP_AUTH_USER'];
echo "用戶名: " . $username;
$password = $_SERVER['PHP_AUTH_PW'];
echo "密碼: " . $password;
$ip_address = $_SERVER['REMOTE_ADDR'];
echo "IP地址: " . $ip_address;
$server_name = $_SERVER['SERVER_NAME'];
echo "服務器域名: " . $server_name;
$request_method = $_SERVER['REQUEST_METHOD'];
echo "請求方法: " . $request_method;
$script_path = $_SERVER['SCRIPT_FILENAME'];
echo "腳本路徑: " . $script_path;
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
echo "用戶代理: " . $http_user_agent;
這些示例展示了如何從$_SERVER
全局變量中提取有關用戶和服務器的信息。請注意,某些信息可能需要根據您的應用程序進行適當的處理和驗證。