Skip to content

Commit db785b7

Browse files
committed
Adds IPv6 documentation
1 parent 41c4c1f commit db785b7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,47 @@ class Pdp\Uri\Url#6 (8) {
197197
}
198198
```
199199

200+
### IPv6 Support
201+
202+
Parsing IPv6 hosts is no different that parsing standard hosts. Setting `$host = 'http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:8080/';`
203+
in the *Parsing URLs* example would return:
204+
205+
```
206+
class Pdp\Uri\Url#6 (8) {
207+
private $scheme =>
208+
string(4) "http"
209+
private $host =>
210+
class Pdp\Uri\Url\Host#5 (4) {
211+
private $subdomain =>
212+
NULL
213+
private $registerableDomain =>
214+
NULL
215+
private $publicSuffix =>
216+
NULL
217+
private $host =>
218+
string(38) "[2001:db8:85a3:8d3:1319:8a2e:370:7348]"
219+
}
220+
private $port =>
221+
string(4) "8080"
222+
private $user =>
223+
NULL
224+
private $pass =>
225+
NULL
226+
private $path =>
227+
string(1) "/"
228+
private $query =>
229+
NULL
230+
private $fragment =>
231+
NULL
232+
}
233+
```
234+
235+
**IMPORTANT**: IPv6 url host names *must* be enclosed in square brackets. They
236+
will not be parsed properly otherwise.
237+
238+
> Hat tip to [@geekwright](https://github.com/geekwright) for adding IPv6 support in a
239+
> [bugfix pull request](https://github.com/jeremykendall/php-domain-parser/pull/35).
240+
200241
### Parsing Domains ###
201242

202243
If you'd like to parse the domain (or host) portion only, you can use

0 commit comments

Comments
 (0)