0% found this document useful (0 votes)
150 views

How To Grab IP Address With 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)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views

How To Grab IP Address With 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)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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('ipaddresses.txt'', '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 anythingyouwant.php 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