IdnaEncoder::encode( string|WpOrgRequestsStringable $hostname )
Encode a hostname using Punycode
Parameters
- $hostname
-
(Required) Hostname
Return
(string) Punycode-encoded hostname
Source
File: wp-includes/Requests/src/IdnaEncoder.php
public static function encode($hostname) {
if (InputValidator::is_string_or_stringable($hostname) === false) {
throw InvalidArgument::create(1, '$hostname', 'string|Stringable', gettype($hostname));
}
$parts = explode('.', $hostname);
foreach ($parts as &$part) {
$part = self::to_ascii($part);
}
return implode('.', $parts);
}