GetURLPart()

Syntax

Result$ = GetURLPart(URL$, Parameter$)
Description
Get a specific part of the given URL$. This can be a named parameter in the URL string or another part of the URL.

Parameters

URL$ The URL$ to get the part from. The URL$ may contain parameters, which are useful when a scripting language such as: (PHP) is being used on that server. The syntax is as follows: (http://www.purebasic.com/index.php3?test=1) Here, the parameter is named "test" and its associated value is "1".
Parameter$ The parameter to return from the URL$. The parameters are not case-sensitive. This parameter can also specify one of the following constants to access other parts of the URL:
  #PB_URL_Protocol: returns the protocol from the URL$
  #PB_URL_Site: returns the site from the URL$
  #PB_URL_Port: returns the port from the URL$ (if specified)
  #PB_URL_Parameters: returns all the parameters from the URL$
  #PB_URL_Path: returns the path from the URL$
  #PB_URL_User: returns the username from the URL$ (if specified)
  #PB_URL_Password: returns the password from the URL$ (if specified)

Return value

Returns the parameter value or other part of the URL.

Example

  URL$ = "http://user:pass@www.purebasic.com:80/index.php3?test=1&ok=2"

  Debug GetURLPart(URL$, #PB_URL_Protocol) ; Will print "http"
  Debug GetURLPart(URL$, #PB_URL_Site)     ; Will print "www.purebasic.com"
  Debug GetURLPart(URL$, #PB_URL_Port)     ; Will print "80"
  Debug GetURLPart(URL$, #PB_URL_Parameters) ; Will print "test=1&ok=2"
  Debug GetURLPart(URL$, #PB_URL_Path)     ; Will print "index.php3"
  Debug GetURLPart(URL$, #PB_URL_User)     ; Will print "user"
  Debug GetURLPart(URL$, #PB_URL_Password) ; Will print "pass"
  Debug GetURLPart(URL$, "test")           ; Will print "1"
  Debug GetURLPart(URL$, "ok")             ; Will print "2"

See Also

SetURLPart(), URLDecoder()

Supported OS

All

<- GetHTTPHeader() - Http Index - HTTPProgress() ->