public function valid_url(string $str = null): bool
	{
		if (empty($str))
		{
			return false;
		}
		elseif (preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $str, $matches))
		{
			if (! in_array($matches[1], ['http', 'https'], true))
			{
				return false;
			}

			$str = $matches[2];
		}

		$str = 'http://' . $str;

		return (filter_var($str, FILTER_VALIDATE_URL) !== false);
	}
public function valid_url(string $str = null): bool
	{
		if (empty($str))
		{
			return false;
		}
		elseif (preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $str, $matches))
		{
			if (! in_array($matches[1], ['http', 'https'], true))
			{
				return false;
			}

			$str = $matches[2];
		}

		$str = 'http://' . $str;

		return (filter_var($str, FILTER_VALIDATE_URL) !== false);
	}
public function valid_url ( string $ str = null ) : bool { if ( empty ( $ str ) ) { return false ; } elseif ( preg_match ( '/^(?:([^:]*)\:)?\/\/(.+)$/' , $ str , $ matches ) ) { if ( ! in_array ( $ matches [ 1 ] , [ 'http' , 'https' ] , true ) ) { return false ; } $ str = $ matches [ 2 ] ; } $ str = 'http://' . $ str ; return ( filter_var ( $ str , FILTER_VALIDATE_URL ) !== false ) ; }
Checks a URL to ensure it's formed correctly.

@param string $str

@return boolean
Checks a URL to ensure it s formed correctly .