Requests_IRI::set_host() WordPress Method
The Requests_IRI::set_host() method is used to set the host for the IRI. The host can be either an IP address or a domain name. If the host is an IP address, it must be in the correct format for an IRI (i.e. it must be a valid IPv4 or IPv6 address). If the host is a domain name, it must be a fully qualified domain name.
Requests_IRI::set_host( string $ihost ) #
Set the ihost. Returns true on success, false on failure (if there are any invalid characters).
Parameters
- $ihost
(string)(Required)
Return
(bool)
Source
File: wp-includes/Requests/IRI.php
protected function set_host($ihost) { if ($ihost === null) { $this->ihost = null; return true; } if (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') { if (Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) { $this->ihost = '[' . Requests_IPv6::compress(substr($ihost, 1, -1)) . ']'; } else { $this->ihost = null; return false; } } else { $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); // Lowercase, but ignore pct-encoded sections (as they should // remain uppercase). This must be done after the previous step // as that can add unescaped characters. $position = 0; $strlen = strlen($ihost); while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) { if ($ihost[$position] === '%') { $position += 3; } else { $ihost[$position] = strtolower($ihost[$position]); $position++; } } $this->ihost = $ihost; } $this->scheme_normalization(); return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub