Change Language:
USA English French Deutsch (Germen) Spanish Portugese Italian Nederlands (Dutch) Polish Russian Swidesh Arabic Korian Chinese Japanese UK English Bookmark and Share

Get visitors IP address

How to get visitors IP address? If you want to get your web site visitor's IP address then PHP provides you complete solution for this. I made a function to get IP address of visitor.

PHP Codes

See example result here
Download example here

<?php
function visitorip() {
    if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
    elseif (getenv('HTTP_X_FORWARDED_FOR'))    $ip = getenv('HTTP_X_FORWARDED_FOR');
    elseif (getenv('HTTP_X_FORWARDED')) $ip = getenv('HTTP_X_FORWARDED');
    elseif (getenv('HTTP_FORWARDED_FOR')) $ip = getenv('HTTP_FORWARDED_FOR');
    elseif (getenv('HTTP_FORWARDED')) $ip = getenv('HTTP_FORWARDED');
    else $ip = $_SERVER['REMOTE_ADDR'];
    return $ip;
}

echo "Your IP address is ".visitorip();

?>
In result web site visitor's ip address will appear. In example above i made a function named visitorip() will check all conditions for getting ip and will return ip address. echo command of PHP will receive ip address will display on page.

See example result here
Download example here


See Also or Related Articles:

Contact Us - RSS Feed
Get Page Rank 10 - SEO Experiment

Feedback Form