--- layout: default title: Host modifiers --- Host modifiers ======= The following modifiers update and normalize the URI host component according to RFC3986 or RFC3987. ## UriModifier::hostToAscii Converts the host into its ascii representation according to RFC3986: ~~~php This method will have no effect on League URI objects as this conversion is done by default.
## UriModifier::hostToUnicode Converts the host into its idn representation according to RFC3986: ~~~php This method will have no effect on League URI objects because the object always transcode the host component into its RFC3986/ascii representation. ## UriModifier::removeZoneIdentifier Removes the host zone identifier if present ~~~php Hosts are hierarchical components whose labels are indexed from right to left. ~~~php $uri = Http::createFromString("http://www.example.com/path/to/the/sky/"); $newUri = UriModifier::replaceLabel($uri, 2, 'admin.shop'); echo $newUri; //display"http://admin.shop.example.com/path/to/the/sky" ~~~ The previous example can be rewritten using negative offset: ~~~php $uri = Http::createFromString("http://www.example.com/path/to/the/sky/"); $newUri = UriModifier::replaceLabel($uri, -1, 'admin.shop'); echo $newUri; //display"http://admin.shop.example.com/path/to/the/sky" ~~~ ## UriModifier::removeLabels Removes selected labels from the current URI host. Labels are indicated using an array containing the labels offsets. ~~~php $uri = Http::createFromString("http://www.localhost.com/path/to/the/sky/"); $newUri = UriModifier::removeLabels($uri, 2, 0); echo $newUri; //display "http://localhost/path/the/sky/" ~~~ The previous example can be rewritten using negative offset: ~~~php $uri = Http::createFromString("http://www.example.com/path/to/the/sky/"); $newUri = UriModifier::removeLabels($uri, -1, -3); echo $newUri; //display "http://localhost/path/the/sky/" ~~~