Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/thephpleague/uri
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 31, 2017
2 parents ba71674 + 81849f4 commit 11180cd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/5.0/parser/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ var_export($parser($uri));

## Validating the URI host component

If you have a host **string** you can validate it against the parser as shown below:
If you have a host **string** you can validate it against the parser. The host is considered to be valid if it is:

- an empty string;
- a IPv4;
- a formatted IPv6 (with or without its zone identifier);
- a registered name;

A registered name is a [domain name](http://tools.ietf.org/html/rfc1034) subset according to [RFC1123](http://tools.ietf.org/html/rfc1123#section-2.1). As such a registered name can not, for example, contain an `_`. The registered name can be RFC3987 or RFC3986 compliant.

~~~php
<?php
Expand All @@ -182,6 +189,6 @@ use League\Uri\Parser;
$parser = new Parser();
$parser->isHost('example.com'); //returns true
$parser->isHost('/path/to/yes'); //returns false
~~~

The string can be RFC3987 or RFC3986 compliant.
$parser->isHost('[:]'); //returns true
$parser->isHost('[127.0.0.1]'); //returns false
~~~

0 comments on commit 11180cd

Please sign in to comment.