0

Why is there no documentation for $_SERVER[ HTTP_CLIENT_IP ] in php on official documentation php.net?

It seems like there have not have any kind documentation about $_SERVER[ HTTP_CLIENT_IP ] in the internet. Not even reference website such as tutorialpoint or w3school have information about this.

php.net: http://php.net/manual/en/reserved.variables.server.php

tutorial point: https://www.tutorialspoint.com/php/php_predefined_variables.htm

w3school: https://www.w3schools.com/php/php_superglobals.asp

Yet, there are many comments or tutorials in forums uses $_SERVER[ HTTP_CLIENT_IP ] to get a more accurate visitor's IP address. Such as:

stackoverflow questions:Will the value of a set $_SERVER['HTTP_CLIENT_IP'] be an empty string?

information stack exchange: https://security.stackexchange.com/questions/129662/best-approach-to-get-users-ip/129664#129664

Also, there are mention about this in the user contributed notes in php.net, but nothing official

So, is $_SERVER[ HTTP_CLIENT_IP ] actually a real thing as official documentation does not have information about this?

Can $_SERVER[ HTTP_CLIENT_IP ] actually get the "real" IP address of the visitor in a shared network? Thank You

Programmer
  • 151
  • 1
  • 12
  • As [this answer](https://stackoverflow.com/a/7446010/15880) notes, `HTTP_CLIENT_IP` isn't a standard HTTP or CGI header. For that matter, this is a client defined header, so even if it or `HTTP_X_FORWARDED_FOR` is present, you have no idea if they're accurate. – Powerlord Jun 09 '18 at 05:24
  • Sometimes users access the internet via a gateway, this means that all external requests from every user on that internal network will come from the IP address of the gateway and not the users PC. Just the same that if you have a router at home, the IP will be the address of the router and not your desktop or laptops IP. – Nigel Ren Jun 09 '18 at 06:38

1 Answers1

1

The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

From http://php.net/manual/en/reserved.variables.server.php

HTTP_CLIENT_IP is not in CGI/1.1 specification and this name generates by web server. Because of this HTTP_CLIENT_IP may not be in docs.

zen
  • 980
  • 6
  • 18