3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ipaddress = ''; if($_SERVER['HTTP_X_FORWARDED_FOR'] && ($_SERVER['HTTP_X_FORWARDED_FOR']<>$ipaddress)){ $proxies=explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']); $ipaddress=$proxies[count($proxies)-1]; //$ipaddress=$proxies[0]; }else{ if (getenv('HTTP_CLIENT_IP')){ $ipaddress = getenv('HTTP_CLIENT_IP'); }elseif(getenv('HTTP_X_FORWARDED_FOR')){ $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); }elseif(getenv('HTTP_X_FORWARDED')){ $ipaddress = getenv('HTTP_X_FORWARDED'); }elseif(getenv('HTTP_FORWARDED_FOR')){ $ipaddress = getenv('HTTP_FORWARDED_FOR'); }elseif(getenv('HTTP_FORWARDED')){ $ipaddress = getenv('HTTP_FORWARDED'); }elseif(getenv('REMOTE_ADDR')){ $ipaddress = getenv('REMOTE_ADDR'); }else{ $ipaddress = 'UNKNOWN'; } } //echo $ipaddress; ?>
Output for 5.3.0 - 7.1.0
Notice: Undefined index: HTTP_X_FORWARDED_FOR in /in/qHlVK on line 4
Output for 4.3.0 - 5.2.17
Notice: Undefined index: HTTP_X_FORWARDED_FOR in /in/qHlVK on line 4