在PHP中,可以使用$_SERVER
全局變量來獲取服務(wù)器環(huán)境變量信息。以下是一些常用的服務(wù)器環(huán)境變量信息的示例:
$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;
這些示例只是一小部分常見的服務(wù)器環(huán)境變量信息,$_SERVER
全局變量中包含了大量的服務(wù)器環(huán)境變量信息,可以根據(jù)自己的需求來獲取相應(yīng)的信息。