mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@53059 c90b9560-bf6c-de11-be94-00142212c4b1
276 lines
9.2 KiB
XML
276 lines
9.2 KiB
XML
<!-- $Revision: 1.13 $ -->
|
|
<reference id="ref.url">
|
|
<title>URL Functions</title>
|
|
<titleabbrev>URLs</titleabbrev>
|
|
|
|
<refentry id="function.base64-decode">
|
|
<refnamediv>
|
|
<refname>base64_decode</refname>
|
|
<refpurpose>Decodes data encoded with MIME base64</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>base64_decode</function></funcdef>
|
|
<paramdef>string <parameter>encoded_data</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>base64_decode</function> decodes
|
|
<parameter>encoded_data</parameter> and returns the original
|
|
data. The returned data may be binary.
|
|
</para>
|
|
<para>
|
|
See also: <function>base64_encode</function>, RFC-2045 section
|
|
6.8.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.base64-encode">
|
|
<refnamediv>
|
|
<refname>base64_encode</refname>
|
|
<refpurpose>Encodes data with MIME base64</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>base64_encode</function></funcdef>
|
|
<paramdef>string <parameter>data</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>base64_encode</function> returns
|
|
<parameter>data</parameter> 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.
|
|
</para>
|
|
<para>
|
|
Base64-encoded data takes about 33% more space than the original
|
|
data.</para>
|
|
<para>
|
|
See also:
|
|
<function>base64_decode</function>,
|
|
<function>chunk_split</function>,
|
|
RFC-2045 section 6.8.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.parse-url">
|
|
<refnamediv>
|
|
<refname>parse_url</refname>
|
|
<refpurpose>Parse a URL and return its components</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>array <function>parse_url</function></funcdef>
|
|
<paramdef>string <parameter>url</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
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".
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.rawurldecode">
|
|
<refnamediv>
|
|
<refname>rawurldecode</refname>
|
|
<refpurpose>Decode URL-encoded strings</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>rawurldecode</function></funcdef>
|
|
<paramdef>string <parameter>str</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string in which the sequences with percent
|
|
(<literal>%</literal>) signs followed by two hex digits have been
|
|
replaced with literal characters. For example, the string
|
|
<screen>foo%20bar%40baz</screen> decodes into <screen>foo
|
|
bar@baz</screen>.
|
|
</para>
|
|
<simpara>
|
|
See also <function>rawurlencode</function>,
|
|
<function>urldecode</function>,
|
|
<function>urlencode</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.rawurlencode">
|
|
<refnamediv>
|
|
<refname>rawurlencode</refname>
|
|
<refpurpose>URL-encode according to RFC1738</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>rawurlencode</function></funcdef>
|
|
<paramdef>string <parameter>str</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string in which all non-alphanumeric characters except
|
|
<screen>-_.</screen> have been replaced with a percent
|
|
(<literal>%</literal>) sign followed by two hex digits. This is
|
|
the encoding described in RFC1738 for protecting literal
|
|
characters from being interpreted as special URL delimiters, and
|
|
for protecting URL's from being mangled by transmission media
|
|
with character conversions (like some email systems). For
|
|
example, if you want to include a password in an ftp url:
|
|
<example>
|
|
<title><function>rawurlencode</function> example 1</title>
|
|
<programlisting role="php">
|
|
echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
|
|
'@ftp.my.com/x.txt">';
|
|
</programlisting>
|
|
</example>
|
|
Or, if you pass information in a path info component of the url:
|
|
<example>
|
|
<title><function>rawurlencode</function> example 2</title>
|
|
<programlisting role="php">
|
|
echo '<A HREF="http://x.com/department_list_script/',
|
|
rawurlencode ('sales and marketing/Miami'), '">';
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
See also <function>rawurldecode</function>,
|
|
<function>urldecode</function>,
|
|
<function>urlencode</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.urldecode">
|
|
<refnamediv>
|
|
<refname>urldecode</refname>
|
|
<refpurpose>Decodes URL-encoded string</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>urldecode</function></funcdef>
|
|
<paramdef>string <parameter>str</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Decodes any <literal>%<replaceable>##</replaceable></literal>
|
|
encoding in the given string. The decoded string is returned.
|
|
<example>
|
|
<title><function>urldecode</function> example</title>
|
|
<programlisting role="php">
|
|
$a = split ('&', $QUERY_STRING);
|
|
$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++;
|
|
}
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
See also <function>urlencode</function>,
|
|
<function>rawurlencode</function>,
|
|
<function>rawurldecode</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.urlencode">
|
|
<refnamediv>
|
|
<refname>urlencode</refname>
|
|
<refpurpose>URL-encodes string</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>string <function>urlencode</function></funcdef>
|
|
<paramdef>string <parameter>str</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string in which all non-alphanumeric characters except
|
|
<literal>-_.</literal> have been replaced with a percent
|
|
(<literal>%</literal>) sign followed by two hex digits and spaces
|
|
encoded as plus (<literal>+</literal>) signs. It is encoded the
|
|
same way that the posted data from a WWW form is encoded, that is
|
|
the same way as in
|
|
<literal>application/x-www-form-urlencoded</literal> media type.
|
|
This differs from the RFC1738 encoding (see
|
|
<function>rawurlencode</function>) 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 convenient way to pass variables to the next page:
|
|
<example>
|
|
<title><function>urlencode</function> example</title>
|
|
<programlisting role="php">
|
|
echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Note: Be careful about variables that may match HTML entities.
|
|
Things like &amp, &copy and &pound are parsed by the
|
|
browser and the actual entity is used instead of the desired
|
|
variable name. This is an obvious hassle that the W3C has been
|
|
telling people about for years. The reference is here:
|
|
<ulink url="&url.argsep;">&url.argsep;</ulink> PHP supports
|
|
changing the argument separator to the W3C-suggested semi-colon
|
|
through the arg_separator .ini directive. Unfortunately most user
|
|
agents do not send form data in this semi-colon separated format.
|
|
A more portable way around this is to use &amp; instead of
|
|
& as the separator. You don't need to change PHP's
|
|
arg_separator for this. Leave it as &, but simply encode
|
|
your URLs using <function>htmlentities</function>(urlencode($data)).
|
|
<example>
|
|
<title><function>urlencode/htmlentities</function> example</title>
|
|
<programlisting role="php">
|
|
echo '<A HREF="mycgi?foo=', htmlentities (urlencode ($userinput) ), '">';
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
See also <function>urldecode</function>,
|
|
<function>htmlentities</function>,
|
|
<function>rawurldecode</function>,
|
|
<function>rawurlencode</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
</reference>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
-->
|