URL functions
URLs
parse_url
parse a URL and return its components
Description
array parse_url
string url
This function returns an associative array returning any of the
various components of the URL that are present. This includes the
"scheme", "host", "port", "user", "pass", "path", "query", and
"fragment".
urldecode
decodes URL-encoded string
Description
string urldecode
string str
Decodes any %##
encoding in the given string. The decoded string is returned.
urldecode() example
$a = split ('&', $querystring);
$i = 0;
while ($i < count ($a)) {
$b = split ('=', $a [$i]);
echo 'Value for parameter ', htmlspecialchars (urldecode ($b [0])),
' is ', htmlspecialchars (urldecode ($b [1])), "<BR>";
$i++;
}
See also urlencode
urlencode
URL-encodes string
Description
string urlencode
string str
Returns a string in which all non-alphanumeric characters except
-_. have been replaced with a percent
(%) sign followed by two hex digits and spaces
encoded as plus (+) signs. It is encoded the
same way that the posted data from a WWW form is encoded, that is
the same way as in
application/x-www-form-urlencoded media type.
This differs from the RFC1738 encoding (see rawurlencode ) in that
for historical reasons, spaces are encoded as plus (+ ) signs.
This function is convenient when encoding a string to be used in
a query part of an URL, as a convinient way to pass variables to
the next page:
urlencode() example
echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';
See also urldecode
base64_encode
encodes data with MIME base64
Description
string base64_encode
string data
base64_encode returns
data encoded with base64. This encoding
is designed to make binary data survive transport through
transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original
data.
See also:
base64_decode,
chunk_split,
RFC-2045 section 6.8.
base64_decode
decodes data encoded with MIME base64
Description
string base64_decode
string encoded_data
base64_decode decodes
encoded_data and returns the original
data. The returned data may be binary.
See also:
base64_encode,
RFC-2045 section 6.8.