Php 如果语句值检查不起作用

Php 如果语句值检查不起作用,php,if-statement,geolocation,geo,Php,If Statement,Geolocation,Geo,我正在使用GeoPlugin检查我的访客来自哪里。我使用$geo[“geoplugin\u CountryCode”]获取国家代码 我通过在PHP中执行if检查来重定向用户。我不知道为什么,但它总是将我重定向到if语句中的最后一个链接[EN]。代码应该将我发送到[NL]站点,因为我来自荷兰。我没有使用vpn/代理或其他东西 if ($countryCode == 'NL') { header('Location: http://notworkingsite.com/GeoPlugin/N

我正在使用GeoPlugin检查我的访客来自哪里。我使用
$geo[“geoplugin\u CountryCode”]获取国家代码

我通过在PHP中执行if检查来重定向用户。我不知道为什么,但它总是将我重定向到if语句中的最后一个链接[EN]。代码应该将我发送到[NL]站点,因为我来自荷兰。我没有使用vpn/代理或其他东西

if ($countryCode == 'NL') {
    header('Location: http://notworkingsite.com/GeoPlugin/NL/', TRUE, 302);
}
if ($countryCode == 'TR') {
    header('Location: http://notworkingsite.com/GeoPlugin/TR/', TRUE, 302);
}
if ($countryCode == 'DE') {
    header('Location: http://notworkingsite.com/GeoPlugin/DE/', TRUE, 302);
}
else {
    header('Location: http://notworkingsite.com/GeoPlugin/EN/', TRUE, 302);
} 
整版

<?php

$user_ip = getenv('REMOTE_ADDR');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$countryCode = $geo["geoplugin_countryCode"];

if ($countryCode == 'NL') {
    header('Location: http://notworkingsite.com/GeoPlugin/NL/', TRUE, 302);
}
if ($countryCode == 'TR') {
    header('Location: http://notworkingsite.com/GeoPlugin/TR/', TRUE, 302);
}
if ($countryCode == 'DE') {
    header('Location: http://notworkingsite.com/GeoPlugin/DE/', TRUE, 302);
}
else {
    header('Location: http://notworkingsite.com/GeoPlugin/EN/', TRUE, 302);
}

?>

$geo=unserialize(…您确定内容是一个序列化的php数组吗?是的,因为如果没有if语句,在$countryCode上执行回显时会显示my countryCode[NL],您可以自己尝试代码,在变量上执行回显。请发布var_dump($geo)的输出;