function get_content($URL){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$ip = $_SERVER['REMOTE_ADDR'];
$url = "http://ip-api.com/xml/". $ip. "?fields=regionName";
$veri = get_content($url);
$xml = simplexml_load_string($veri);
echo (string)$xml->regionName ;
hiç bir veri yazmıyor ekrana..
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$veri=file_get_contents("http://ip-api.com/xml/$ip");
preg_match("@<regionName>(.*?)</regionName>@si",$veri,$yazdir);
$yazdir[1]=str_replace('<![CDATA[','',$yazdir[1]);
$yazdir[1]=str_replace(']]>','',$yazdir[1]);
echo "$yazdir[1]";
?>
bu kodda hata veriyor hocam teşekkürler ikinize de. ancak yapamadım