Codeigniter get current ip address
In this post we willshow you Codeigniter get current ip address and we will give different method for and example for Codeigniter get current ip address
$this->input->ip_address()
is used to urge the information science address of current user.
Method 1 :: Codeigniter get current information science address
Syntax for Codeigniter get current information science address
$current_ip_address = $this->input->ip_address(); echo $current_ip_address;
Will come this user’s information science if information science is invalid it returns 0.0.0.0
.
Method 2 :: Codeigniter get current information science address
For Codeigniter get current information science address, to urge the remote information science address, in PHP, you may use $_SERVER['HTTP_X_FORWARDED_FOR']
, CodeIgniter is doing constant factor behind the scenes.
function current_ip_address() { // acquire the information science address but you want, you'll wish to try to to extra validation, etc.. $current_ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; return $current_ip_address; }
Method 3 :: Codeigniter get current information science address
For Codeigniter get current information science address, to urge the remote information science address, in PHP, you may use $_SERVER[‘REMOTE_ADDR’], CodeIgniter is doing constant factor behind the scenes.
function current_ip_address() { $current_ip_address_string = @getenv("HTTP_X_FORWARDED_FOR"); $current_ip_address = explode(",",$current_ip_address_string); echo $current_ip_address[sizeof($current_ip_address)-1]; }
Laravel Load More Data on Page Scroll AND Laravel Custom Helpers AND how to laravel latest version AND Laravel login using google