在PHP中,可以使用$_SERVER
全局变量来获取服务器环境变量信息。以下是一些常用的服务器环境变量信息的示例:
$server_ip = $_SERVER['SERVER_ADDR'];
echo "Server IP address: " . $server_ip;
$server_port = $_SERVER['SERVER_PORT'];
echo "Server Port: " . $server_port;
$server_os = $_SERVER['SERVER_SOFTWARE'];
echo "Server OS: " . $server_os;
$current_script = $_SERVER['SCRIPT_FILENAME'];
echo "Current Script: " . $current_script;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
echo "User Agent: " . $user_agent;
这些示例只是一小部分常见的服务器环境变量信息,$_SERVER
全局变量中包含了大量的服务器环境变量信息,可以根据自己的需求来获取相应的信息。