Get Users IP Address | CSS-Tricks

PHOTO EMBED

Mon Jun 22 2020 13:02:38 GMT+0000 (UTC)

Saved by @Amna #php

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
     $ip=$_SERVER['REMOTE_ADDR'];
}
content_copyCOPY

https://css-tricks.com/snippets/php/get-users-ip-address/