3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ip=$_SERVER['REMOTE_ADDR']; $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if(getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if(getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if(getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if(getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if(getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; echo "OLD IP: "; echo $ip; echo "<br>"; echo "NEW IP: "; echo $ipaddress; echo "<br>"; echo getenv('HTTP_CLIENT_IP'); echo "<br>"; echo getenv('HTTP_X_FORWARDED_FOR'); echo "<br>"; echo getenv('HTTP_X_FORWARDED'); echo "<br>"; echo getenv('HTTP_FORWARDED_FOR'); echo "<br>"; echo getenv('HTTP_FORWARDED'); echo "<br>"; echo getenv('REMOTE_ADDR'); ?>
based on Dj036
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
Notice: Undefined index: REMOTE_ADDR in /in/2mSAI on line 3 OLD IP: <br>NEW IP: UNKNOWN<br><br><br><br><br><br>