0% found this document useful (0 votes)
293 views1 page

Grab IP Address Using PHP

The document provides examples of how to grab a visitor's IP address with PHP. The variable $_SERVER['REMOTE_ADDR'] contains the IP address and can be used to print the IP address to the page, write it to a text file, or for other purposes. Examples are given to print the IP address to the page and write it to a new text file.

Uploaded by

adhieresthenes
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
293 views1 page

Grab IP Address Using PHP

The document provides examples of how to grab a visitor's IP address with PHP. The variable $_SERVER['REMOTE_ADDR'] contains the IP address and can be used to print the IP address to the page, write it to a text file, or for other purposes. Examples are given to print the IP address to the page and write it to a new text file.

Uploaded by

adhieresthenes
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

How to grab IP address with PHP

Today Ill be showing you how to grab somebodies IP address when they visit a page.

The variable to use is $_SERVER['REMOTE_ADDR'] - Its that simple. You can use it for just about anything, here are a few examples.

Printing the Users IP Address:

<?php print ($_SERVER['REMOTE_ADDR'], "I'm Watching You!"); ?>

Printing it to a File:

<?php $ip = $_SERVER['REMOTE_ADDR']; $handle = fopen('[Link]'', 'a+); fwrite($handle, $ip); fwrite($handle, "\n"); fclose($handle); ?>

All you have to do, is to make a text file and insert any of these codes or one of your own and save it as [Link] Then upload it to your website and it'll do the trick :P The Possibilities for what you can use this to are endless. Good luck :D

You might also like