PHP code example of xmsjdev / ip2region

1. Go to this page and download the library: Download xmsjdev/ip2region library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xmsjdev / ip2region example snippets



use Xmsjdev\Ip2region\Ip2region;
use Hyperf\Di\Annotation\Inject;

class Example
{
    #[Inject]
    protected Ip2region $ip2region;

    public function query()
    {
        $address = $this->ip2region->memorySearch($ip);
        var_dump($address);
    }
}