GetURLPart()

Syntax

Result$ = GetURLPart(URL$, Parameter$)
Description
Get a specific part of the given URL$. A 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". This command will return the value of the given Parameter$. The parameters are not case-sensitive. Moreover, Parameter$ may be one of the following constants, which are used to access a specific part of a 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)

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"
This command can be very useful to parse a URL when writing a CGI program.

Supported OS

All

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