Check if a string is a valid url.

@param   string  $url    url string to check

@return bool
486128
public function isUrl($url)
    {
        $path = parse_url($url, PHP_URL_PATH);
        $encoded_path = array_map('urlencode', explode('/', $path));
        $url = str_replace($path, implode('/', $encoded_path), $url);

        return filter_var($url, FILTER_VALIDATE_URL);
    }
390819
public static function isUrl($value)
    {
        if (\strlen($value) > 0 && $value[0] == $value[1] && $value[0] == "/") {
            $value = 'http:'.$value;
        }

        return false !== \filter_var($value, FILTER_VALIDATE_URL, ['options' => ['flags' => FILTER_FLAG_PATH_REQUIRED]]);
    }
107600
function nicifyUrl($url) {
			$fullurl = $url;
		    $url = urldecode(strtolower($url));
		    $url = $this->stripit($url);
		    // clean up url path
		    $url = explode("/",$url);
		    $arrUrl = parse_url($url[0]);
		    $urlRet = $arrUrl['path'];
		    // valid?
		    if($this->validateTheUrl($urlRet)){
		        return true;
		    }
		    else{
		        return false;
		    }
		}
209971
private function validateUrl($url)
    {
        $parsed = parse_url($url);
        if (empty($parsed['scheme'])
            || empty($parsed['host'])
            || $parsed['scheme'] !== 'https'
            || substr($url, -4) !== '.pem'
            || !preg_match($this->hostPattern, $parsed['host'])
        ) {
            throw new InvalidSnsMessageException(
                'The certificate is located on an invalid domain.'
            );
        }
    }
740764
static function isShortUrl($url){
        // Overall URL length - May be a max of 30 characters
        if (strlen($url) > 30) return false;

        $parts = parse_url($url);

        if(isset($parts["path"])){
            $path = $parts["path"];
            $pathParts = explode("/", $path);

            // Number of '/' after protocol (http://) - Max 2
            if (count($pathParts) > 2) return false;

            // URL length after last '/' - May be a max of 10 characters
            $lastPath = array_pop($pathParts);
            if (strlen($lastPath) > 10) return false;

            // Max length of host
            if (strlen($parts["host"]) > 10) return false;
        } else {
            return false;
        }

        // Get headers and see if Location is set.
        $headers = get_headers($url, 1);
        if(!is_array($headers) || !isset($headers['Location'])){
            return false;
        }

        return true;
    }
693483
public static function url_exist($url)
    {
        $headers = @get_headers($url);

        if (empty($headers) || 'HTTP/1.1 404 Not Found' == $headers[0]) {
            return false;
        }

        return true;
    }
1370223
protected function urlValidate($url)
    {
        return (
            filter_var($url, FILTER_VALIDATE_URL) &&
            ($parsed = parse_url($url)) !== false &&
            $this->urlValidateHost($parsed['host']) &&
            $this->urlValidateScheme($parsed['scheme'])
        );
    }
309937
public static function isHttp(string $url)
    {
        $url = UrlHelper::validateUrl($url);

        $parsedUrl = parse_url($url);
        if ($parsedUrl === false) {
            throw new InvalidArgumentException("The provided url is not valid: $url");
        }

        return $parsedUrl["scheme"] === UrlHelper::HTTP_SCHEME;
    }
328119
public function isAccessible($url)
    {
        $context = $this->getContext($url);

        return is_resource(@fopen($url, 'r', null, $context));
    }
177613
private boolean isInvalidURL(String url) {
        try {
            final URL u = new URL(url);
            u.toURI();
        } catch (MalformedURLException | URISyntaxException e) {
            LOGGER.trace("URL is invalid: {}", url);
            return true;
        }
        return false;
    }
77592
static function isSameHost($url)
    {
        $urlParts = parse_url($url);
        if(
            isset($_SERVER['SERVER_NAME']) &&
            $_SERVER['SERVER_NAME'] == $urlParts['host']
        ){
            return true;
        }

        return false;
    }
1291181
public static function verify_site_url($url) {
		$url = trim($url);
		if (!$url || strlen($url) > 64)
			return false;
		return filter_var($url, FILTER_VALIDATE_URL);
	}
1037779
private function validateUrl(string $url)
    {
        if (!(new UrlSpecification)->isSatisfiedBy(new Url($url))) {
            throw new UrlException(sprintf(
                'The string "%s" is not a valid url',
                $url
            ));
        }
    }
754696
public static function parseUrl($url)
    {
        if (!\is_string($url)) {
            throw new \InvalidArgumentException('URL must be a string');
        }

        $encodedUrl = preg_replace_callback(
            '%[^:/@?&=#]+%u',
            function ($matches) { return rawurlencode($matches[0]); },
            $url
        );

        $parts = \is_string($encodedUrl) ? parse_url($encodedUrl) : false;
        if ($parts === false) {
            throw new \InvalidArgumentException("Malformed URL: {$url}");
        }

        return $parts;
    }
639017
protected function getUrlStatus($url)
    {
        if($this->isValidUrl($url)) {
            ini_set('allow_url_fopen', 1);
            $url = @get_headers($url, 1);
            if($url) {
                $status = explode(' ',$url[0]);
                return (int) $status[1];
            }
        }
        else {
            return 404;
        }
    }
712364
private static function cleanUrl($url)
    {
        $result = '';
        $inner = false;

        for ($i = 0; $i < strlen($url); $i++) {
            if (!$inner) {
                if ($url[$i] != '{') {
                    $result .= $url[$i];
                } else {
                    $result .= '{';
                    $inner = true;
                }
            } else {
                if ($url[$i] == '}') {
                    $result .= '}';
                    $inner = false;
                }
            }
        }

        return $result;
    }
100303
public function validate($url)
    {
        if (null !== ($headers = $this->getHeader($url))) {
            $statusCode = $this->getStatusCode($headers);
            // see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
            return ($statusCode >= 200 && $statusCode < 300);
        }
        return false;
    }