PHP code example of wdy / district

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

    

wdy / district example snippets


use Wdy\District\District;

$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';

$d = new District($key);

$response = $d->getDistrict('成都');


getDistrict(string $keywords, int $subdistrict = 0, string $output = 'JSON')

//容器获取方式
app('district')->getDistrict('成都');

//依赖注入方式
public function __construct(District $district)
{
    $this->district = $district;
}