不使用PHP显示的标志

不使用PHP显示的标志,php,Php,我正在尝试根据用户的IP地址显示国旗。以前,我让它工作得很好,但我想我不小心做错了什么。经过数小时的调试,我似乎无法找到导致错误的原因。它没有抛出任何错误,只是没有显示任何标志或任何“echo”语句。有人有什么建议吗?代码如下,请提前感谢 function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($n

我正在尝试根据用户的IP地址显示国旗。以前,我让它工作得很好,但我想我不小心做错了什么。经过数小时的调试,我似乎无法找到导致错误的原因。它没有抛出任何错误,只是没有显示任何标志或任何“echo”语句。有人有什么建议吗?代码如下,请提前感谢

function iptocountry($ip) {  
   $numbers = preg_split( "/\./", $ip);  
   include("ip_files/".$numbers[0].".php");  
   $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);  
   foreach($ranges as $key => $value){  
      if($key<=$code){  
         if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}  
        }  
}  
if ($two_letter_country_code==""){$two_letter_country_code="unknown";}  
return $two_letter_country_code;  
$IPaddress=$_SERVER['REMOTE_ADDR'];  
$two_letter_country_code=iptocountry($IPaddress);  

include("ip_files/countries.php");  
$three_letter_country_code=$countries[ $two_letter_country_code][0];  
$country_name=$countries[$two_letter_country_code][1];  

echo "Two letters code: $two_letter_country_code<br>";  
echo "Three letters code: $three_letter_country_code<br>";  
echo "Country name: $country_name<br>";  

// To display flag  
$file_to_check="flags/$two_letter_country_code.gif";  
if (file_exists($file_to_check)){  
            echo `"<img src=$file_to_check width=30 height=15><br>"`;  
            }else{  
            echo `"<img src=flags/noflag.gif width=30 height=15><br>"`;  
            }  


}  
?>  
功能iptocountry($ip){
$numbers=preg_split(“/\./”,$ip);
包括(“ip_文件/”$numbers[0]。.php”);
$code=($numbers[0]*16777216)+($numbers[1]*65536)+($numbers[2]*256)+($numbers[3]);
foreach($key=>$value的范围){
如果($key=$code){$two_letter_country_code=$ranges[$key][1];break;}
}  
}  
如果($two-letter\u country\u code==“”){$two-letter\u country\u code=“未知”}
返回$2字母\国家\代码;
$IPaddress=$\u服务器['REMOTE\u ADDR'];
$2字母\国家\代码=iptocountry($IPaddress);
包括(“ip_文件/countries.php”);
$three_letter_country_code=$countries[$three_letter_country_code][0];
$country_name=$countries[$two_letter_country_code][1];
回显“两个字母代码:$2个字母国家代码
”; 回声“三字母代码:$三字母国家代码
”; echo“国家名称:$Country_name
”; //展示旗帜 $file\u to\u check=“flags/$two\u letter\u country\u code.gif”; 如果(文件_存在($file_to_check)){ 回声`“
”`; }否则{ 回声`“
”`; } } ?>
在函数return语句之后缺少右括号
}


此外,您的代码非常紧凑。您是否考虑过更宽敞的编码风格?这对眼睛真的很有帮助,而且可能会帮助你更快地找到像这样的虫子。

非常感谢你,愚蠢的错误,我一定会考虑到这一点。