WpOrg\Requests
Iri::parse_iri()
Parse an IRI into scheme/authority/path/query/fragment segments
Method of the class: Iri{}
No Hooks.
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->parse_iri( $iri );
- $iri(string) (required)
- -
Iri::parse_iri() Iri::parse iri code WP 6.6.2
protected function parse_iri($iri) { $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); $has_match = preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match); if (!$has_match) { throw new Exception('Cannot parse supplied IRI', 'iri.cannot_parse', $iri); } if ($match[1] === '') { $match['scheme'] = null; } if (!isset($match[3]) || $match[3] === '') { $match['authority'] = null; } if (!isset($match[5])) { $match['path'] = ''; } if (!isset($match[6]) || $match[6] === '') { $match['query'] = null; } if (!isset($match[8]) || $match[8] === '') { $match['fragment'] = null; } return $match; }