public static function encodeUrl($strUrl)
	{
		if ($strUrl == '')
		{
			return '';
		}

		// Empty anchor (see #3555) or insert tag
		if ($strUrl == '#' || strncmp($strUrl, '{{', 2) === 0)
		{
			return $strUrl;
		}

		// E-mail address
		if (strncmp($strUrl, 'mailto:', 7) === 0)
		{
			return static::encodeEmail($strUrl);
		}

		$arrUrl = parse_url($strUrl);

		if (!isset($arrUrl['scheme']))
		{
			throw new \InvalidArgumentException(sprintf('Expected a FQDN, got "%s"', $strUrl));
		}

		// Scheme
		if (isset($arrUrl['scheme']))
		{
			$arrUrl['scheme'] .= ((substr($strUrl, \strlen($arrUrl['scheme']), 3) == '://') ? '://' : ':');
		}

		// User
		if (isset($arrUrl['user']))
		{
			$arrUrl['user'] .= isset($arrUrl['pass']) ? ':' : '@';
		}

		// Password
		if (isset($arrUrl['pass']))
		{
			$arrUrl['pass'] .= '@';
		}

		// Host
		if (isset($arrUrl['host']))
		{
			$arrUrl['host'] = static::encode($arrUrl['host']);
		}

		// Port
		if (isset($arrUrl['port']))
		{
			$arrUrl['port'] = ':' . $arrUrl['port'];
		}

		// Path does not have to be altered

		// Query
		if (isset($arrUrl['query']))
		{
			$arrUrl['query'] = '?' . $arrUrl['query'];
		}

		// Anchor
		if (isset($arrUrl['fragment']))
		{
			$arrUrl['fragment'] = '#' . $arrUrl['fragment'];
		}

		$strReturn = '';

		foreach (array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment') as $key)
		{
			if (isset($arrUrl[$key]))
			{
				$strReturn .= $arrUrl[$key];
			}
		}

		return $strReturn;
	}
public static function encodeUrl($strUrl)
	{
		if ($strUrl == '')
		{
			return '';
		}

		
		if ($strUrl == '
		{
			return $strUrl;
		}

		
		if (strncmp($strUrl, 'mailto:', 7) === 0)
		{
			return static::encodeEmail($strUrl);
		}

		$arrUrl = parse_url($strUrl);

		if (!isset($arrUrl['scheme']))
		{
			throw new \InvalidArgumentException(sprintf('Expected a FQDN, got "%s"', $strUrl));
		}

		
		if (isset($arrUrl['scheme']))
		{
			$arrUrl['scheme'] .= ((substr($strUrl, \strlen($arrUrl['scheme']), 3) == ':
		}

		
		if (isset($arrUrl['user']))
		{
			$arrUrl['user'] .= isset($arrUrl['pass']) ? ':' : '@';
		}

		
		if (isset($arrUrl['pass']))
		{
			$arrUrl['pass'] .= '@';
		}

		
		if (isset($arrUrl['host']))
		{
			$arrUrl['host'] = static::encode($arrUrl['host']);
		}

		
		if (isset($arrUrl['port']))
		{
			$arrUrl['port'] = ':' . $arrUrl['port'];
		}

		

		
		if (isset($arrUrl['query']))
		{
			$arrUrl['query'] = '?' . $arrUrl['query'];
		}

		
		if (isset($arrUrl['fragment']))
		{
			$arrUrl['fragment'] = '
		}

		$strReturn = '';

		foreach (array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment') as $key)
		{
			if (isset($arrUrl[$key]))
			{
				$strReturn .= $arrUrl[$key];
			}
		}

		return $strReturn;
	}
public static function encodeUrl ( $ strUrl ) { if ( $ strUrl == '' ) { return '' ; } // Empty anchor (see #3555) or insert tag if ( $ strUrl == '#' || strncmp ( $ strUrl , '{{' , 2 ) === 0 ) { return $ strUrl ; } // E-mail address if ( strncmp ( $ strUrl , 'mailto:' , 7 ) === 0 ) { return static :: encodeEmail ( $ strUrl ) ; } $ arrUrl = parse_url ( $ strUrl ) ; if ( ! isset ( $ arrUrl [ 'scheme' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected a FQDN, got "%s"' , $ strUrl ) ) ; } // Scheme if ( isset ( $ arrUrl [ 'scheme' ] ) ) { $ arrUrl [ 'scheme' ] .= ( ( substr ( $ strUrl , \ strlen ( $ arrUrl [ 'scheme' ] ) , 3 ) == '://' ) ? '://' : ':' ) ; } // User if ( isset ( $ arrUrl [ 'user' ] ) ) { $ arrUrl [ 'user' ] .= isset ( $ arrUrl [ 'pass' ] ) ? ':' : '@' ; } // Password if ( isset ( $ arrUrl [ 'pass' ] ) ) { $ arrUrl [ 'pass' ] .= '@' ; } // Host if ( isset ( $ arrUrl [ 'host' ] ) ) { $ arrUrl [ 'host' ] = static :: encode ( $ arrUrl [ 'host' ] ) ; } // Port if ( isset ( $ arrUrl [ 'port' ] ) ) { $ arrUrl [ 'port' ] = ':' . $ arrUrl [ 'port' ] ; } // Path does not have to be altered // Query if ( isset ( $ arrUrl [ 'query' ] ) ) { $ arrUrl [ 'query' ] = '?' . $ arrUrl [ 'query' ] ; } // Anchor if ( isset ( $ arrUrl [ 'fragment' ] ) ) { $ arrUrl [ 'fragment' ] = '#' . $ arrUrl [ 'fragment' ] ; } $ strReturn = '' ; foreach ( array ( 'scheme' , 'user' , 'pass' , 'host' , 'port' , 'path' , 'query' , 'fragment' ) as $ key ) { if ( isset ( $ arrUrl [ $ key ] ) ) { $ strReturn .= $ arrUrl [ $ key ] ; } } return $ strReturn ; }
Encode the domain in an URL

@param string $strUrl The URL

@return string The encoded URL

@throws \InvalidArgumentException
Encode the domain in an URL