$_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) "abkIPQGLSVc@V00Zsmn6TwAACCc"
  ["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(116) "http://www.kwery.fr/Formation/_other_lessons/php-intro/courses/01-PHP/02-Les variables Superglobales/02-$_SERVER.php"
  ["CFG_CLUSTER"]=>
  string(10) "cluster110"
  ["HTTP_HOST"]=>
  string(12) "www.kwery.fr"
  ["HTTP_X_PREDICTOR"]=>
  string(1) "1"
  ["HTTP_X_FORWARDED_FOR"]=>
  string(14) "216.73.216.161"
  ["HTTP_X_FORWARDED_PROTO"]=>
  string(4) "http"
  ["HTTP_X_OVHREQUEST_ID"]=>
  string(32) "15052d2e390e4d95ed18b6472650df96"
  ["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-ngln8 (squid/6.10)"
  ["HTTP_CACHE_CONTROL"]=>
  string(14) "max-age=259200"
  ["HTTP_X_FORWARDED_PORT"]=>
  string(2) "80"
  ["HTTP_X_REMOTE_PORT"]=>
  string(5) "50736"
  ["HTTP_X_REMOTE_IP"]=>
  string(14) "216.73.216.161"
  ["HTTP_X_REMOTE_PROTO"]=>
  string(4) "http"
  ["HTTP_FORWARDED"]=>
  string(49) "for=216.73.216.161; proto=http; host=www.kwery.fr"
  ["HTTP_X_IPLB_UNIQUE_ID"]=>
  string(49) "D849D8A1:C630_D5BA2113:0050_69B9083C_2BBDB:22BA85"
  ["HTTP_REMOTE_IP"]=>
  string(14) "216.73.216.161"
  ["SERVER_SIGNATURE"]=>
  string(0) ""
  ["SERVER_SOFTWARE"]=>
  string(6) "Apache"
  ["SERVER_NAME"]=>
  string(12) "www.kwery.fr"
  ["SERVER_ADDR"]=>
  string(11) "10.110.20.9"
  ["SERVER_PORT"]=>
  string(2) "80"
  ["REMOTE_ADDR"]=>
  string(14) "216.73.216.161"
  ["SERVER_ADMIN"]=>
  string(23) "postmaster@www.kwery.fr"
  ["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) "61322"
  ["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(1773733949.8908)
  ["REQUEST_TIME"]=>
  int(1773733949)
  ["argv"]=>
  array(0) {
  }
  ["argc"]=>
  int(0)
  ["register_shutdown_function"]=>
  int(1)
}