Skip to content

Commit 4861638

Browse files
committed
Updates IDNA documentation
1 parent 515c292 commit 4861638

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,31 @@ class Pdp\Uri\Url#6 (8) {
100100
}
101101
```
102102

103+
### Convenience Methods
104+
105+
A magic __get() method is provided to access the above object properties. Obtaining the
106+
public suffix for a parsed domain is as simple as:
107+
108+
``` php
109+
<?php
110+
111+
$host = 'waxaudio.com.au';
112+
$url = $parser->parseUrl($host);
113+
$publicSuffix = $url->host->publicSuffix;
114+
115+
// $publicSuffix = 'com.au'
116+
```
117+
103118
### IDNA Support
104119

120+
[IDN (Internationalized Domain Name)](http://en.wikipedia.org/wiki/Internationalized_domain_name)
121+
support was added in version `1.4.0`. Both unicode domains and their ASCII equivalents
122+
are supported.
123+
105124
#### Unicode
106125

107-
[IDN (Internationalized Domain Name)](http://en.wikipedia.org/wiki/Internationalized_domain_name)
108-
support was added in 1.4.0. Setting `$host = 'Яндекс.РФ';` (Russian-Cyrillic)
109-
in the previous example would return:
126+
Parsing IDNA hosts is no different that parsing standard hosts. Setting `$host = 'Яндекс.РФ';` (Russian-Cyrillic)
127+
in the *Parsing URLs* example would return:
110128

111129
```
112130
class Pdp\Uri\Url#6 (8) {
@@ -141,7 +159,7 @@ class Pdp\Uri\Url#6 (8) {
141159
#### ASCII (Punycode)
142160

143161
If you choose to provide the ASCII equivalent of the unicode domain name
144-
(`$host = 'http://xn--d1acpjx3f.xn--p1ai';` in the case of the above example),
162+
(`$host = 'http://xn--d1acpjx3f.xn--p1ai';` in the case of the *Parsing URLs* example),
145163
the ASCII equivalent will be returned by the parser:
146164

147165
```
@@ -174,21 +192,6 @@ class Pdp\Uri\Url#6 (8) {
174192
}
175193
```
176194

177-
### Convenience Methods
178-
179-
A magic __get() method is provided to access the above object properties. Obtaining the
180-
public suffix for a parsed domain is as simple as:
181-
182-
``` php
183-
<?php
184-
185-
$host = 'waxaudio.com.au';
186-
$url = $parser->parseUrl($host);
187-
$publicSuffix = $url->host->publicSuffix;
188-
189-
// $publicSuffix = 'com.au'
190-
```
191-
192195
### Parsing Domains ###
193196

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

0 commit comments

Comments
 (0)