WordPress at a glance
function is not described

PHPMailer\PHPMailer

PHPMailer::isValidHost() public WP 1.0

Validate whether a string contains a valid value to use as a hostname or IP address. IPv6 addresses must include [], e.g. [::1], not just ::1.

{} It's a method of the class: PHPMailer{}

No Hooks.

Return

true|false.

Usage

$result = PHPMailer::isValidHost( $host );
$host(string) (required)
The host name or IP address to check

Code of PHPMailer::isValidHost() WP 5.7.2

<?php
public static function isValidHost($host)
{
    //Simple syntax limits
    if (
        empty($host)
        || !is_string($host)
        || strlen($host) > 256
        || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host)
    ) {
        return false;
    }
    //Looks like a bracketed IPv6 address
    if (strlen($host) > 2 && substr($host, 0, 1) === '[' && substr($host, -1, 1) === ']') {
        return filter_var(substr($host, 1, -1), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
    }
    //If removing all the dots results in a numeric string, it must be an IPv4 address.
    //Need to check this first because otherwise things like `999.0.0.0` are considered valid host names
    if (is_numeric(str_replace('.', '', $host))) {
        //Is it a valid IPv4 address?
        return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
    }
    if (filter_var('http://' . $host, FILTER_VALIDATE_URL) !== false) {
        //Is it a syntactically valid hostname?
        return true;
    }

    return false;
}