Backend Development

Getting and validating IPs in PHP. (NOOBS Only!)

Submitted by LightningXd, , Thread ID: 19268

Thread Closed
LightningXd
Novice
Level:
0
Reputation:
-1
Posts:
30
Likes:
0
Credits:
3
10-03-2016, 12:26 AM
#1
Hi guys,

So, if you are looking to make a basic IP grabbing tool in PHP or something that requires you to get the user's IP address then all you have to do is:

PHP Code:
$_SERVER['REMOTE_ADDR'


This is actually the most secure way of getting the IP of the visitor/user, and a way to validate this IP address is:

PHP Code:
filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP). 

Users browsing this thread: 1 Guest(s)