public function toString($to = self::TO_FRAGMENT, $schemaRelative = false)
	{
		if($to == static::TO_SCHEME)
		{
			return $this->scheme;
		}
		
		if($schemaRelative || empty($this->scheme))
		{
			$uri = empty($this->host) ? '' : '//';
		}
		else
		{
			$uri = empty($this->host) ? '' : ($this->scheme . '://');
		}
		
		if(isset($this->username) && !empty($this->host))
		{
			$uri .= $this->username;
				
			if(isset($this->password))
			{
				$uri .= ':' . $this->password;
			}
				
			$uri .= '@';
		}
		
		$uri .= $this->getHost(true) . '/';
		
		if($to == static::TO_HOST)
		{
			return $uri;
		}
		
		$uri .= $this->getPath(true);
		
		if($to == static::TO_PATH)
		{
			return $uri;
		}
		
		if(!empty($this->query))
		{
			$uri .= '?' . $this->getQueryString();
		}
		
		if($to == static::TO_QUERY)
		{
			return $uri;
		}
		
		if(!empty($this->fragment))
		{
			$uri .= '#' . $this->fragment;
		}
		
		return $uri;
	}
public function toString($to = self::TO_FRAGMENT, $schemaRelative = false)
	{
		if($to == static::TO_SCHEME)
		{
			return $this->scheme;
		}
		
		if($schemaRelative || empty($this->scheme))
		{
			$uri = empty($this->host) ? '' : '//';
		}
		else
		{
			$uri = empty($this->host) ? '' : ($this->scheme . '://');
		}
		
		if(isset($this->username) && !empty($this->host))
		{
			$uri .= $this->username;
				
			if(isset($this->password))
			{
				$uri .= ':' . $this->password;
			}
				
			$uri .= '@';
		}
		
		$uri .= $this->getHost(true) . '/';
		
		if($to == static::TO_HOST)
		{
			return $uri;
		}
		
		$uri .= $this->getPath(true);
		
		if($to == static::TO_PATH)
		{
			return $uri;
		}
		
		if(!empty($this->query))
		{
			$uri .= '?' . $this->getQueryString();
		}
		
		if($to == static::TO_QUERY)
		{
			return $uri;
		}
		
		if(!empty($this->fragment))
		{
			$uri .= '#' . $this->fragment;
		}
		
		return $uri;
	}
public function toString ( $ to = self :: TO_FRAGMENT , $ schemaRelative = false ) { if ( $ to == static :: TO_SCHEME ) { return $ this -> scheme ; } if ( $ schemaRelative || empty ( $ this -> scheme ) ) { $ uri = empty ( $ this -> host ) ? '' : '//' ; } else { $ uri = empty ( $ this -> host ) ? '' : ( $ this -> scheme . '://' ) ; } if ( isset ( $ this -> username ) && ! empty ( $ this -> host ) ) { $ uri .= $ this -> username ; if ( isset ( $ this -> password ) ) { $ uri .= ':' . $ this -> password ; } $ uri .= '@' ; } $ uri .= $ this -> getHost ( true ) . '/' ; if ( $ to == static :: TO_HOST ) { return $ uri ; } $ uri .= $ this -> getPath ( true ) ; if ( $ to == static :: TO_PATH ) { return $ uri ; } if ( ! empty ( $ this -> query ) ) { $ uri .= '?' . $ this -> getQueryString ( ) ; } if ( $ to == static :: TO_QUERY ) { return $ uri ; } if ( ! empty ( $ this -> fragment ) ) { $ uri .= '#' . $ this -> fragment ; } return $ uri ; }
Renders an encoded URI.

@param integer $to Render parts (left to right) up to this part.
@param boolean $schemaRelative Create a schema-relative URI?
@return string
Renders an encoded URI .