public static function isValid($hostname)
    {
        $hostname = trim($hostname);

        // Strip the wrapping square brackets from IPv6 addresses.

        if (Str::startsWith($hostname, '[') && Str::endsWith($hostname, ']')) {
            $hostname = substr($hostname, 1, -1);
        }

        return (bool)filter_var($hostname, FILTER_VALIDATE_IP);
    }
public static function isValid($hostname)
    {
        $hostname = trim($hostname);

        // Strip the wrapping square brackets from IPv6 addresses.

        if (Str::startsWith($hostname, '[') && Str::endsWith($hostname, ']')) {
            $hostname = substr($hostname, 1, -1);
        }

        return (bool)filter_var($hostname, FILTER_VALIDATE_IP);
    }
public static function isValid ( $ hostname ) { $ hostname = trim ( $ hostname ) ; // Strip the wrapping square brackets from IPv6 addresses. if ( Str :: startsWith ( $ hostname , '[' ) && Str :: endsWith ( $ hostname , ']' ) ) { $ hostname = substr ( $ hostname , 1 , - 1 ) ; } return ( bool ) filter_var ( $ hostname , FILTER_VALIDATE_IP ) ; }
Check if the input is a valid IP address. Recognizes both IPv4 and IPv6 addresses.

@param string $hostname Hostname that will be checked

@return boolean
Check if the input is a valid IP address . Recognizes both IPv4 and IPv6 addresses .