vrana Tue Apr 19 06:01:48 2005 EDT
Modified files:
/phpdoc/en/reference/url/functions urlencode.xml
Log:
urlencode can't produce & (spotted by Michal Molhanec)
http://cvs.php.net/diff.php/phpdoc/en/reference/url/functions/urlencode.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/url/functions/urlencode.xml
diff -u phpdoc/en/reference/url/functions/urlencode.xml:1.7
phpdoc/en/reference/url/functions/urlencode.xml:1.8
--- phpdoc/en/reference/url/functions/urlencode.xml:1.7 Wed Jan 28 19:35:32 2004
+++ phpdoc/en/reference/url/functions/urlencode.xml Tue Apr 19 06:01:45 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/url.xml, last change in rev 1.2 -->
<refentry id="function.urlencode">
<refnamediv>
@@ -42,14 +42,15 @@
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
+ <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 htmlentities(urlencode($data)).
+ your URLs using <function>htmlentities</function> or
+ <function>htmlspecialchars</function>.
</para>
<para>
<example>
@@ -57,7 +58,8 @@
<programlisting role="php">
<![CDATA[
<?php
-echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">';
+$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
+echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
]]>
</programlisting>