IPIP.php 389 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Components;
  3. use ipip\db\City;
  4. class IPIP
  5. {
  6. /**
  7. * 查询IP地址的详细信息
  8. *
  9. * @param string $ip IPv4
  10. *
  11. * @return array|null
  12. */
  13. public static function ip($ip)
  14. {
  15. $filePath = public_path('ipip.ipdb');
  16. $loc = new City($filePath);
  17. $result = $loc->findMap($ip, 'CN');
  18. return $result;
  19. }
  20. }