Get IP Address in PHP

0
21
PHP

This tutorial explains how to get IP Address of client in PHP.

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

echo $ip_cl; //IP Address

LEAVE A REPLY

Please enter your comment!
Please enter your name here