codeigniter get user ip

PHP
$ip = $this->input->ip_address();
echo $ip;

Source

Also in PHP: