6.18. URL Functions
Extraction Functions
The URL extraction functions extract components from HTTP URLs(or any valid URIs conforming to RFC 2396).The following syntax is supported:
- [protocol:][//host[:port]][path][?query][#fragment]
The extracted components do not contain URI syntax separatorssuch as :
or ?
.
urlextract_fragment
(_url) → varcharReturns the fragment identifier from
url
.urlextract_host
(_url) → varcharReturns the host from
url
.urlextract_parameter
(_url, name) → varcharReturns the value of the first query string parameter named
name
fromurl
. Parameter extraction is handled in the typical manneras specified by RFC 1866#section-8.2.1.urlextract_path
(_url) → varcharReturns the path from
url
.urlextract_port
(_url) → bigintReturns the port number from
url
.urlextract_protocol
(_url) → varcharReturns the protocol from
url
.urlextract_query
(_url) → varchar- Returns the query string from
url
.
Encoding Functions
urlencode
(_value) → varcharEscapes
value
by encoding it so that it can be safely included inURL query parameter names and values:- Alphanumeric characters are not encoded.
- The characters
.
,-
,*
and_
are not encoded. - The ASCII space character is encoded as
+
. - All other characters are converted to UTF-8 and the bytes are encodedas the string
%XX
whereXX
is the uppercase hexadecimalvalue of the UTF-8 byte.
urldecode
(_value) → varchar- Unescapes the URL encoded
value
.This function is the inverse ofurl_encode()
.