WpOrg\Requests
Iri::to_uri
Convert an IRI to a URI (or parts thereof)
Метод класса: Iri{}
Хуков нет.
Возвращает
Строку|false. URI if IRI is valid, false otherwise.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->to_uri( $iri );
- $iri(строка|true|false) (обязательный)
- IRI to convert (or false from \WpOrg\Requests\Iri::get_iri()).
Код Iri::to_uri() Iri::to uri WP 7.0.4
protected function to_uri($iri) {
if (!is_string($iri)) {
return false;
}
static $non_ascii;
if (!$non_ascii) {
$non_ascii = implode('', range("\x80", "\xFF"));
}
$position = 0;
$strlen = strlen($iri);
while (($position += strcspn($iri, $non_ascii, $position)) < $strlen) {
$iri = substr_replace($iri, sprintf('%%%02X', ord($iri[$position])), $position, 1);
$position += 3;
$strlen += 2;
}
return $iri;
}