0
我試圖根據用戶位置顯示內容。例如,顯示是否在澳大利亞以外的國家。根據位置使用PHP顯示內容
我一直在使用此鏈接中的文件:http://www.geoplugin.com/webservices/php
這是我一直在使用的代碼。即使當我改變位置時,它也會始終顯示回顯。
<?php
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
// If we wanted to change the base currency, we would uncomment the following line
// $geoplugin->currency = 'EUR';
$geoplugin->locate();
echo "Geolocation results for {$geoplugin->ip}: <br />\n".
"Country Name: {$geoplugin->countryName} <br />\n".
"Country Code: {$geoplugin->countryCode} <br />\n";
if ($geoplugin->countryName != "Australia") {
//our visitor is not using the same currency as the base currency
echo "Show International Popup";
}
?>
乾杯
你如何改變位置進行測試呢? – developerwjk
你已經在迴應上面的國家名稱,它與「澳大利亞」不同嗎?另外@developerwjk代理或只是僞造了geoplugin結果。 –
將位置更改爲澳大利亞境外時,「$ geoplugin-> countryName」的結果是什麼? – Drakes