[PHP-DOC] cvs: phpdoc / global.ent /en/functions url.xml From: Rasmus Lerdorf (rasmus <email protected>)
Date: 09/06/00

rasmus Wed Sep 6 09:58:53 2000 EDT

  Modified files:
    /phpdoc global.ent
    /phpdoc/en/functions url.xml
  Log:
  urlencode() note
  
  
Index: phpdoc/global.ent
diff -u phpdoc/global.ent:1.48 phpdoc/global.ent:1.49
--- phpdoc/global.ent:1.48 Wed Sep 6 03:17:50 2000
+++ phpdoc/global.ent Wed Sep 6 09:58:53 2000
@@ -1,6 +1,6 @@
 <!-- -*- SGML -*-
 
- $Id: global.ent,v 1.48 2000/09/06 10:17:50 jmcastagnetto Exp $
+ $Id: global.ent,v 1.49 2000/09/06 16:58:53 rasmus Exp $
 
  Contains global "macros" for all the SGML documents.
 
@@ -8,6 +8,7 @@
 <!ENTITY url.adabas "http://www.adabas.com/">
 <!ENTITY url.adobe "http://www.adobe.com/">
 <!ENTITY url.apache "http://www.apache.org/">
+<!ENTITY url.argsep "http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2">
 <!ENTITY url.aspell "http://aspell.sourceforge.net/">
 <!ENTITY url.bcmath "http://www.php.net/extra/number4.tar.gz">
 <!ENTITY url.browscap "http://php.netvision.net.il/browser-id.php3">
Index: phpdoc/en/functions/url.xml
diff -u phpdoc/en/functions/url.xml:1.6 phpdoc/en/functions/url.xml:1.7
--- phpdoc/en/functions/url.xml:1.6 Mon Aug 7 09:07:02 2000
+++ phpdoc/en/functions/url.xml Wed Sep 6 09:58:53 2000
@@ -221,12 +221,31 @@
      <example>
       <title><function>Urlencode</function> example</title>
       <programlisting role="php">
-echo '&lt;A HREF="mycgi?foo=', urlencode ($userinput), '">';
+echo '&lt;A HREF="mycgi?foo=', urlencode ($userinput), '"&gt;';
       </programlisting>
      </example>
     </para>
+ <para>Note: Be careful about variables that may match HTML entities.
+ Things like &amp;amp, &amp;copy and &amp;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;amp; instead of &amp; as the
+ separator. You don't need to change PHP's arg_separator for this. Leave
+ it as &amp;, but simply encode your URLs using:
+ <example>
+ <title><function>Urlencode/htmlentities</function> example</title>
+ <programlisting role="php">
+echo '&lt;A HREF="mycgi?foo=', htmlentities (urlencode ($userinput) ), '"&gt;';
+ </programlisting>
+ </example>
+
     <para>
      See also <function>urldecode</function>,
+ <function>htmlentities</function>,
                           <function>rawurldecode</function>,
                                                         <function>rawurlencode</function>.
     </para>