$_SERVER

$_SERVER — Variables de serveur et d'exécution

Description

$_SERVER est un tableau contenant des informations comme les en-têtes, dossiers et chemins du script. Les entrées de ce tableau sont créées par le serveur web. Il n'y a aucune garantie que tous les serveurs les rempliront tous ; certains en oublieront quelques-unes et en rajouteront de nouvelles non mentionnées ici.

Vous trouverez une liste des différents indices de cette variable sur php.net

Exemple :
var_dump($_SERVER);
Donne actuellement sur ce serveur :
array(56) {
  ["USER"]=>
  string(8) "belzoras"
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["APP_ENGINE"]=>
  string(3) "php"
  ["APP_ENGINE_VERSION"]=>
  string(3) "5.4"
  ["ENVIRONMENT"]=>
  string(10) "production"
  ["DOCUMENT_ROOT"]=>
  string(18) "/home/belzoras/www"
  ["UNIQUE_ID"]=>
  string(27) "aacbQYzR0aRHMKyiYjSC3gAAAjo"
  ["GEOIP_COUNTRY_CODE"]=>
  string(2) "US"
  ["GEOIP_COUNTRY_NAME"]=>
  string(13) "United States"
  ["GEOIP_REGION"]=>
  string(2) "CA"
  ["GEOIP_CITY"]=>
  string(11) "Santa Paula"
  ["GEOIP_DMA_CODE"]=>
  string(3) "803"
  ["GEOIP_AREA_CODE"]=>
  string(3) "805"
  ["GEOIP_LATITUDE"]=>
  string(9) "34.355598"
  ["GEOIP_LONGITUDE"]=>
  string(11) "-119.070099"
  ["SCRIPT_URL"]=>
  string(97) "/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["SCRIPT_URI"]=>
  string(117) "http://belzorash.com/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["CFG_CLUSTER"]=>
  string(10) "cluster110"
  ["HTTP_HOST"]=>
  string(13) "belzorash.com"
  ["HTTP_X_PREDICTOR"]=>
  string(1) "1"
  ["HTTP_X_FORWARDED_FOR"]=>
  string(14) "216.73.216.119"
  ["HTTP_X_FORWARDED_PROTO"]=>
  string(4) "http"
  ["HTTP_X_OVHREQUEST_ID"]=>
  string(32) "5bb1608da207ea9ea1626c8d2d2aa79f"
  ["HTTP_ACCEPT"]=>
  string(3) "*/*"
  ["HTTP_USER_AGENT"]=>
  string(103) "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"
  ["HTTP_ACCEPT_ENCODING"]=>
  string(23) "gzip, br, zstd, deflate"
  ["HTTP_VIA"]=>
  string(45) "1.1 squid-proxy-5b5d847c96-fp7cq (squid/6.10)"
  ["HTTP_CACHE_CONTROL"]=>
  string(14) "max-age=259200"
  ["HTTP_X_FORWARDED_PORT"]=>
  string(2) "80"
  ["HTTP_X_REMOTE_PORT"]=>
  string(5) "39330"
  ["HTTP_X_REMOTE_IP"]=>
  string(14) "216.73.216.119"
  ["HTTP_X_REMOTE_PROTO"]=>
  string(4) "http"
  ["HTTP_FORWARDED"]=>
  string(50) "for=216.73.216.119; proto=http; host=belzorash.com"
  ["HTTP_X_IPLB_UNIQUE_ID"]=>
  string(49) "D849D877:99A2_D5BA2113:0050_69A71B40_F4DB7:15E271"
  ["HTTP_REMOTE_IP"]=>
  string(14) "216.73.216.119"
  ["SERVER_SIGNATURE"]=>
  string(0) ""
  ["SERVER_SOFTWARE"]=>
  string(6) "Apache"
  ["SERVER_NAME"]=>
  string(13) "belzorash.com"
  ["SERVER_ADDR"]=>
  string(11) "10.110.20.9"
  ["SERVER_PORT"]=>
  string(2) "80"
  ["REMOTE_ADDR"]=>
  string(14) "216.73.216.119"
  ["SERVER_ADMIN"]=>
  string(24) "postmaster@belzorash.com"
  ["SCRIPT_FILENAME"]=>
  string(115) "/home/belzoras/www/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["REMOTE_PORT"]=>
  string(5) "64592"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["REQUEST_METHOD"]=>
  string(3) "GET"
  ["QUERY_STRING"]=>
  string(0) ""
  ["REQUEST_URI"]=>
  string(101) "/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les%20variables%20Superglobales/02-$_SERVER.php"
  ["SCRIPT_NAME"]=>
  string(97) "/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["PHP_SELF"]=>
  string(97) "/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["REQUEST_TIME_FLOAT"]=>
  float(1772559169.3706)
  ["REQUEST_TIME"]=>
  int(1772559169)
  ["argv"]=>
  array(0) {
  }
  ["argc"]=>
  int(0)
  ["register_shutdown_function"]=>
  int(1)
}