3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ip = $_SERVER['REMOTE_ADDR']; echo $ip; $url = "http://geoip.nekudo.com/api/" . urlencode($ip); $content = file_get_contents($url); $json = json_decode($content); $lat = $json->location->latitude; $long = $json->location->longitude; ?> <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCKpthp6RdaCNWy83Arx5N6LvwgLYMF2H4"></script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("map"),mapProp); } google.maps.event.addDomListener(window, 'load', initialize); </script> <div align="center" class="map"> </div>
Output for 7.2.0
Notice: Undefined index: REMOTE_ADDR in /in/P3CUv on line 3 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/P3CUv on line 7 Warning: file_get_contents(http://geoip.nekudo.com/api/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/P3CUv on line 7 Notice: Trying to get property 'location' of non-object in /in/P3CUv on line 10 Notice: Trying to get property 'latitude' of non-object in /in/P3CUv on line 10 Notice: Trying to get property 'location' of non-object in /in/P3CUv on line 11 Notice: Trying to get property 'longitude' of non-object in /in/P3CUv on line 11 <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCKpthp6RdaCNWy83Arx5N6LvwgLYMF2H4"></script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("map"),mapProp); } google.maps.event.addDomListener(window, 'load', initialize); </script> <div align="center" class="map"> </div>
Output for 5.3.18 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19, 7.0.4, 7.0.20, 7.1.5 - 7.1.10
Notice: Undefined index: REMOTE_ADDR in /in/P3CUv on line 3 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/P3CUv on line 7 Warning: file_get_contents(http://geoip.nekudo.com/api/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/P3CUv on line 7 Notice: Trying to get property of non-object in /in/P3CUv on line 10 Notice: Trying to get property of non-object in /in/P3CUv on line 10 Notice: Trying to get property of non-object in /in/P3CUv on line 11 Notice: Trying to get property of non-object in /in/P3CUv on line 11 <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCKpthp6RdaCNWy83Arx5N6LvwgLYMF2H4"></script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("map"),mapProp); } google.maps.event.addDomListener(window, 'load', initialize); </script> <div align="center" class="map"> </div>
Output for 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 7.0.3, 7.0.5 - 7.0.6, 7.1.0
Notice: Undefined index: REMOTE_ADDR in /in/P3CUv on line 3 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/P3CUv on line 7 Warning: file_get_contents(http://geoip.nekudo.com/api/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/P3CUv on line 7 Notice: Trying to get property of non-object in /in/P3CUv on line 10 Notice: Trying to get property of non-object in /in/P3CUv on line 10 Notice: Trying to get property of non-object in /in/P3CUv on line 11 Notice: Trying to get property of non-object in /in/P3CUv on line 11 <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCKpthp6RdaCNWy83Arx5N6LvwgLYMF2H4"></script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(51.508742,-0.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("map"),mapProp); } google.maps.event.addDomListener(window, 'load', initialize); </script> <div align="center" class="map"> </div>