URL functions
URL functions
parse_url
Name
parse_url — parse a URL and return its components
Description
array parse_url(string url);
Returns: 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
Name
urldecode — decodes URL-encoded string
Description
string urldecode(string str);
Decodes any %## encoding in the given string. The decoded string is returned.
Example 1. 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
Name
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:
Example 1. urlencode() example
echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';
See also urldecode
base64_encode
Name
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, RFC-2045 section 6.8.
base64_decode
Name
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.