我正在使用-
检索邮政编码<?php $pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/'); ?>
它工作得很好,但是如果没有找到邮政编码,它会显示"None"。我找不到禁用信息的方法。
如果响应为None
,则可以清空该变量。一个简单的检查。
<?php
$pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/');
if($pstcde === "None")
$pstcde = ""; //Empty string. Or you can use unset($pstcde); if you want to unset the variable.
?>