PHP Get Actual IP Address – WortGepresst



STARTSEITE MULTIMEDIA WORTGEPRESST FAMILIENBANDE BOOKMARK PRIVACY


PHP Get Actual IP Address

Method 1

This is the method that I use in my projects to get the actual IP address:

PHP

 
This is a plug-n-play snippet with no modification necessary. Just include in your script and call/use$addressas needed. Covers just about every possible IP-address scenario.
Update!Here is a minimized version of the previous get-IP function:

PHP

 
That’s a bit nicer for copy/paste and quick-use scenarios.

Method 2

Here is another snippet found lurking in the archives. It’s a bit more comprehensive in that it returns not just a single IP address, but an entire array of all possible IP addresses. Great for serious IP analysis..

PHP

 
Again, this snippet is plug-n-play with no modification required. Just plop it in and call the$iparray as needed. The future is yours!

Method 3

Here is an updated/improved version of the technique provided in “Method 1”, above. This is the new preferred method that I use in my own projects.

PHP

 
This technique is more robust than the other methods, in that it returns only one IP address in the case that more than one is reported by any of the server variables.

Font Resize
Contrast
Zur Werkzeugleiste springen