X

Congrats, You are Subscribed to Receive Updates.

How to Get Real IP from Visitor


How to Get Real IP from Visitor. Sometimes, we need to keep track the visitors location, or we need to know the users location with help of IP Address to work a site based on the Visitors location with help of PHP.

function kv_get_user_ip_address(){

    if(filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
    
        return  @$_SERVER['HTTP_CLIENT_IP'];
    
    elseif(filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
   
        return @$_SERVER['HTTP_X_FORWARDED_FOR'];
   
    elseif(filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP))
   
        return $_SERVER['REMOTE_ADDR'];
}

echo kv_get_user_ip_address();

 

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts