mirror of
https://github.com/danog/dns.git
synced 2025-01-22 21:41:11 +01:00
Improve README example
This commit is contained in:
parent
d861050992
commit
78ad81b3dc
10
README.md
10
README.md
@ -17,25 +17,25 @@ composer require amphp/dns
|
|||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/examples/_bootstrap.php';
|
||||||
|
|
||||||
use Amp\Dns;
|
use Amp\Dns;
|
||||||
use Amp\Loop;
|
use Amp\Loop;
|
||||||
|
|
||||||
Loop::run(function () {
|
Loop::run(function () {
|
||||||
$githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
|
$githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
|
||||||
var_dump($githubIpv4);
|
pretty_print_records("github.com", $githubIpv4);
|
||||||
|
|
||||||
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
|
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
|
||||||
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
|
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
|
||||||
|
|
||||||
$firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
|
$firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
|
||||||
var_dump($firstGoogleResult);
|
pretty_print_records("google.com", $firstGoogleResult);
|
||||||
|
|
||||||
$combinedGoogleResult = yield Amp\Dns\resolve("google.com");
|
$combinedGoogleResult = yield Amp\Dns\resolve("google.com");
|
||||||
var_dump($combinedGoogleResult);
|
pretty_print_records("google.com", $combinedGoogleResult);
|
||||||
|
|
||||||
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
|
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
|
||||||
var_dump($googleMx);
|
pretty_print_records("google.com", $googleMx);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user