PHP code example of trrtly / ip2region

1. Go to this page and download the library: Download trrtly/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/ */

    

trrtly / ip2region example snippets



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

class Example
{
    /**
     * @Inject
     * @var Ip2region
     */
    protected $ip2region;

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