src/IpTools.php
public function validIp($ip, $type = 'any', $strict = true)
    {
        switch ($type) {
            case 'any':
                return $this->validIpv4($ip, $strict) || $this->validIpv6($ip, $strict);
                break;
            case 'ipv4':
                return $this->validIpv4($ip, $strict);
                break;
            case 'ipv6':
                return $this->validIpv6($ip, $strict);
                break;
        }
        return false;
    }
public function validIp($ip, $type = 'any', $strict = true)
    {
        switch ($type) {
            case 'any':
                return $this->validIpv4($ip, $strict) || $this->validIpv6($ip, $strict);
                break;
            case 'ipv4':
                return $this->validIpv4($ip, $strict);
                break;
            case 'ipv6':
                return $this->validIpv6($ip, $strict);
                break;
        }
        return false;
    }
public function validIp ( $ ip , $ type = 'any' , $ strict = true ) { switch ( $ type ) { case 'any' : return $ this -> validIpv4 ( $ ip , $ strict ) || $ this -> validIpv6 ( $ ip , $ strict ) ; break ; case 'ipv4' : return $ this -> validIpv4 ( $ ip , $ strict ) ; break ; case 'ipv6' : return $ this -> validIpv6 ( $ ip , $ strict ) ; break ; } return false ; }
Check if ip address is valid

@param string $ip IP address for validation
@param string $type Type of ip address. Possible value are: any, ipv4, ipv6
@param boolean $strict If true - fail validation on reserved and private ip ranges

@return boolean True if ip is valid. False otherwise
Check if ip address is valid