doge 2 months ago
parent
commit
0c530daffc
1 changed files with 4 additions and 3 deletions
  1. 4 3
      extend/Ip.php

+ 4 - 3
extend/Ip.php

@@ -24,7 +24,8 @@ class Ip
     {
         if (empty($ip) === TRUE)
         {
-            return 'N/A';
+            // 始终返回数组,避免调用方 implode() 时报 Invalid arguments
+            return array('N/A');
         }
 
         $nip   = gethostbyname($ip);
@@ -32,7 +33,7 @@ class Ip
 
         if ($ipdot[0] < 0 || $ipdot[0] > 255 || count($ipdot) !== 4)
         {
-            return 'N/A';
+            return array('N/A');
         }
 
         if (isset(self::$cached[$nip]) === TRUE)
@@ -65,7 +66,7 @@ class Ip
 
         if ($index_offset === NULL)
         {
-            return 'N/A';
+            return array('N/A');
         }
 
         fseek(self::$fp, self::$offset['len'] + $index_offset['len'] - 1024);