mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
urlencode() note
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@32141 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
561087fa75
commit
ac45ab3255
1 changed files with 20 additions and 1 deletions
|
@ -221,12 +221,31 @@ while ($i < count ($a)) {
|
|||
<example>
|
||||
<title><function>Urlencode</function> example</title>
|
||||
<programlisting role="php">
|
||||
echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';
|
||||
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:
|
||||
<example>
|
||||
<title><function>Urlencode/htmlentities</function> example</title>
|
||||
<programlisting role="php">
|
||||
echo '<A HREF="mycgi?foo=', htmlentities (urlencode ($userinput) ), '">';
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
See also <function>urldecode</function>,
|
||||
<function>htmlentities</function>,
|
||||
<function>rawurldecode</function>,
|
||||
<function>rawurlencode</function>.
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue