cvs: phpdoc /en/reference/http reference.xml /en/reference/http/functions header.xml headers-sent.xml setcookie.xml
| From: | Sander Roobol | Date: | Wed, 06 Nov 2002 18:34:40 +0000 |
| Subject: | cvs: phpdoc /en/reference/http reference.xml /en/reference/http/functions header.xml headers-sent.xml setcookie.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969349444@lists.php.net to get a copy of this message | ||
sander Wed Nov 6 13:34:40 2002 EDT
Modified files:
/phpdoc/en/reference/http reference.xml
/phpdoc/en/reference/http/functions header.xml headers-sent.xml
setcookie.xml
Log:
Revert.
Index: phpdoc/en/reference/http/reference.xml diff -u phpdoc/en/reference/http/reference.xml:1.5 phpdoc/en/reference/http/reference.xml:1.6 --- phpdoc/en/reference/http/reference.xml:1.5 Wed Nov 6 11:21:38 2002 +++ phpdoc/en/reference/http/reference.xml Wed Nov 6 13:34:39 2002 @@ -1,14 +1,15 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <reference id="ref.http"> - <title>HTTP Ïà¹Øº¯Êý</title> + <title>HTTP functions</title> <titleabbrev>HTTP</titleabbrev> <partintro> <section id="http.intro"> &reftitle.intro; <para> - ÕâЩº¯Êý¿ÉÒÔÈÃÄãÒÀ¾Ý HTTP ±ê×¼ÐÒéÏò¿Í»§¶Ëä¯ÀÀÆ÷·¢ËÍÍ·²¿ÐÅÏ¢¡£ + These functions let you manipulate the output sent back to the + remote browser right down to the HTTP protocol level. </para> </section> Index: phpdoc/en/reference/http/functions/header.xml diff -u phpdoc/en/reference/http/functions/header.xml:1.7 phpdoc/en/reference/http/functions/header.xml:1.8 --- phpdoc/en/reference/http/functions/header.xml:1.7 Wed Nov 6 11:21:40 2002 +++ phpdoc/en/reference/http/functions/header.xml Wed Nov 6 13:34:39 2002 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.header"> <refnamediv> <refname>header</refname> - <refpurpose>Ïòä¯ÀÀÆ÷·¢ËÍÒ»¸ö HTTP Í·²¿ÐÅÏ¢</refpurpose> + <refpurpose>Send a raw HTTP header</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>int</type><methodname>header</methodname> <methodparam><type>string</type><parameter>string</parameter></methodparam> @@ -15,14 +15,17 @@ <methodparam choice="opt"><type>int</type><parameter>http_reponse_code</parameter></methodparam> </methodsynopsis> <para> - <function>header</function> º¯ÊýÓÃÀ´·¢ËÍÒ»¸ö <acronym>HTTP</acronym> - Í·²¿ÐÅÏ¢µ½¿Í»§¶ËµÄä¯ÀÀÆ÷¡£ÓÐ¹Ø <acronym>HTTP</acronym> Í·²¿ÐÅÏ¢µÄ¸ü¶àÄÚÈݲμû¹Ù·½Îĵµ - <ulink url="&spec.http1.1;">HTTP/1.1 specification</ulink>¡£ + <function>header</function> is used to send raw + <acronym>HTTP</acronym> headers. See the <ulink + url="&spec.http1.1;">HTTP/1.1 specification</ulink> for more + information on <acronym>HTTP</acronym> headers. </para> <para> - ¿ÉÑ¡²ÎÊý <parameter>replace</parameter> - ÓÃÀ´±íʾµ±³öÏÖÁ½¸öÏàËÆµÄÍ·²¿ÐÅϢʱ£¬ÊÇÌæ»»Ç°Ò»¸öÏàͬµÄÍ·²¿ÐÅÏ¢»¹ÊÇÔö¼ÓÒ»¸öÏàͬµÄÍ·²¿ÐÅÏ¢¡£Ä¬ÈÏÎªÌæ»»£¬Èç¹ûÄ㽫ÆäÉèΪ - &false; Ôò¿ÉÒÔ¶à´Î·¢ËÍÏàͬµÄÍ·²¿ÐÅÏ¢¡£ÀýÈç: + The optional <parameter>replace</parameter> parameter indicates + whether the header should replace a previous similar header, or + add a second header of the same type. By default it will replace, + but if you pass in &false; as the second argument you can force + multiple headers of the same type. For example: <informalexample> <programlisting role="php"> <![CDATA[ @@ -35,12 +38,15 @@ </informalexample> </para> <para> - µÚ¶þ¸ö¿ÉÑ¡²ÎÊý <parameter>http_response_code</parameter> ±íʾ HTTP - µÄÍ·²¿ÐÅÏ¢µÄ´úÂë¡£(´Ë²ÎÊýÔÚPHP 4.3.0 ±»¼ÓÈë¡£) + The second optional <parameter>http_response_code</parameter> force the + HTTP response code to the specified value. (This parameter is available + in PHP 4.3.0 and higher.) </para> <para> - Í·²¿ÐÅÏ¢µÄ¸ñʽÓÐÁ½ÖÖÐÎʽ¡£Ò»ÖÖÇé¿öÊÇÒÔ×Ö·û ¡°<literal>HTTP/</literal>¡± (²»Çø·Ö´óСд)¿ªÍ·µÄ£¬which will be used to figure out the HTTP status - code to send¡£ÀýÈç,Èç¹ûÄãif you have configured Apache to + There are two special-case header calls. The first is a header + that starts with the string "<literal>HTTP/</literal>" (case is not + significant), which will be used to figure out the HTTP status + code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the <literal>ErrorDocument</literal> directive), you may want to make sure that your script generates the proper status code. @@ -55,7 +61,6 @@ </informalexample> <note> <para> - HTTP Í·²¿ÐÅÏ¢¾³£Ê×Ïȱ»·¢Ë͵½¿Í»§¶Ë£¬ The HTTP status header line will always be the first sent to the client, regardless of the actual <function>header</function> call beeing the first or not. The status may be overridden @@ -65,8 +70,9 @@ </note> <note> <para> - ÔÚ PHP 3 ÖУ¬´Ëº¯ÊýÖ»ÔÚ PHP ÒÔ Apache µÄÄ£¿é»¯ÔËÐеÄʱºòÓÐЧ¡£Äã¿ÉÒÔʹÓà <literal>Status</literal> - À´´ïµ½ÏàͬµÄЧ¹û¡£ + In PHP 3, this only works when PHP is compiled as an Apache + module. You can achieve the same effect using the + <literal>Status</literal> header. <informalexample> <programlisting role="php"> <![CDATA[ @@ -80,7 +86,7 @@ </note> </para> <para> - µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£Not only does + The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a <literal>REDIRECT</literal> (302) status code to the browser unless some <literal>3xx</literal> status code has already been set. @@ -98,11 +104,13 @@ </para> <note> <para> - HTTP/1.1 ±ê×¼ÐèÒªÒ»¸ö¾ø¶ÔµØÖ·µÄ <acronym>URI</acronym> ×öΪ + HTTP/1.1 requires an absolute <acronym>URI</acronym> as argument to <ulink url="&spec.http1.1;-sec14.html#sec14.30">Location:</ulink> - µÄ²ÎÊý, µ«ÓÐһЩ¿Í»§¶ËÖ§³ÖÐéÄâµÄ·¾¶¡£Äãͨ³£¿ÉÒÔʹÓà - <literal>$_SERVER['HTTP_HOST']</literal>¡¢<literal>$_SERVER['PHP_SELF']</literal> - ¼° <function>dirname</function> º¯ÊýÀ´×Ô¼º»ñÈ¡ËùÐèÒªµÄ¾ø¶Ô·¾¶: + including the scheme, hostname and absolute path, but + some clients accept relative URIs. You can usually use + <literal>$_SERVER['HTTP_HOST']</literal>, <literal>$_SERVER['PHP_SELF']</literal> + and <function>dirname</function> to make an absolute URI from a + relative one yourself: <informalexample> <programlisting> <![CDATA[ @@ -117,8 +125,11 @@ </para> </note> <para> - PHP ½Å±¾Í¨³£ÊǶ¯Ì¬¸Ä±äµÄ¡£¿ÉÓÐЩ¿Í»§¶Ë»òһЩ´úÀí·þÎñÆ÷»á°ÑһЩä¯ÀÀ¹ýµÄÄÚÈݸø»º³åÆðÀ´£¬ÕâÑùÄú¸üеĽű¾¾Í²»Äܱ»¿Í»§¶Ë¼°Ê±µÄ·¢ÏÖ£¬Äã¿ÉÒÔͨ¹ý·¢ËÍһЩÀàËÆÏÂÃæÀý×ÓÖеÄÍ·²¿ÐÅÏ¢À´½ûÖ¹ËûÃÇ»º´æÄãµÄÍøÒ³¡£ - <informalexample> + PHP scripts often generate dynamic content that must not be cached + by the client browser or any proxy caches between the server and the + client browser. Many proxies and clients can be forced to disable + caching with + <informalexample> <programlisting role="php"> <![CDATA[ <?php @@ -134,15 +145,16 @@ </informalexample> <note> <para> - Äã¿ÉÄܻᷢÏÖ¼´Ê¹ÄãûÓаÑÉϱߵĴúÂëÈ«²¿Êä³öÄãµÄÍøÒ³Ò²Ã»Óб»»º³åÆðÀ´¡£ÕâÊÇÒòΪһЩÓû§ÔÚËûÃǵÄä¯ÀÀÆ÷µÄÉèÖÃThere are a number of options + You may find that your pages aren't cached even if you don't + output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached. </para> <para> - ÁíÍ⣬<function>session_cache_limiter</function> ºÍ - <literal>session.cache_limiter</literal> configuration + Additionally, <function>session_cache_limiter</function> and + the <literal>session.cache_limiter</literal> configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used. </para> Index: phpdoc/en/reference/http/functions/headers-sent.xml diff -u phpdoc/en/reference/http/functions/headers-sent.xml:1.5 phpdoc/en/reference/http/functions/headers-sent.xml:1.6 --- phpdoc/en/reference/http/functions/headers-sent.xml:1.5 Wed Nov 6 11:19:55 2002 +++ phpdoc/en/reference/http/functions/headers-sent.xml Wed Nov 6 13:34:39 2002 @@ -1,35 +1,39 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.7 --> <refentry id="function.headers-sent"> <refnamediv> <refname>headers_sent</refname> - <refpurpose>²âÊÔÍ·²¿ÐÅÏ¢ÊÇ·ñÒѾ±»·¢ËÍ£¬Èç¹ûÊÇ£¬·µ»Ø &true;</refpurpose> + <refpurpose>Returns &true; if headers have been sent</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>bool</type><methodname>headers_sent</methodname> <methodparam><type>string</type><parameter>&file</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>&line</parameter></methodparam> </methodsynopsis> <para> - Õâ¸öº¯Êý²âÊԽű¾ÖÐÍ·²¿ÐÅÏ¢ÊÇ·ñÒѾ·¢ËÍ£¬Èç¹ûÊÇÔò·µ»Ø &true; ·ñÔò·µ»Ø &false;¡£Ò»µ©Í·²¿ÐÅÏ¢ÒѾ±»·¢ËÍ£¬Ä㽫²»ÄÜÔÙʹÓà <function>header</function> - º¯ÊýÀ´·¢ËÍÆäËüµÄÍ·²¿ÐÅÏ¢¡£Ê¹Óô˺¯Êý¿ÉÒÔʹÄã×î´óÏ޶ȵıÜÃâÀàËÆ "Duplicate headers ..." µÄ´íÎóÐÅÏ¢¡£ + This function returns &true; if the HTTP headers have already been + sent, &false; otherwise. You can't add any more header lines using + the <function>header</function> function once the header block has + already been sent. Using this function you can at least prevent + getting the "Duplicate headers ..." error messages. </para> <para> - Èç¹û¿ÉÏȲÎÊý <parameter>file</parameter> - ¼° <parameter>line</parameter> - ±»Ö¸¶¨£¬Ôòº¯Êý»á·µ»ØÖ¸¶¨ÎļþÖ¸¶¨ÐÐÊýÆðÍ·²¿ÐÅÏ¢µÄ·¢ËÍÇé¿ö¡£ + The function will return the php source file and line number where + output started in the optional <parameter>file</parameter> and + <parameter>line</parameter> parameters if these are given. </para> <note> <simpara> - <parameter>file</parameter> and <parameter>line</parameter> - ²ÎÊýÔÚ PHP 4.3.0 °æ±¾Öб»¼ÓÈë¡£ + <parameter>file</parameter> and <parameter>line</parameter> where + added for PHP 4.3.0. </simpara> </note> <para> - ¸ü¶àϸ½ÚµÄÌÖÂ۲μû <function>header</function>¡£ + See also <function>header</function> for a more detailed discussion + of the matters involved. </para> </refsect1> </refentry> Index: phpdoc/en/reference/http/functions/setcookie.xml diff -u phpdoc/en/reference/http/functions/setcookie.xml:1.9 phpdoc/en/reference/http/functions/setcookie.xml:1.10 --- phpdoc/en/reference/http/functions/setcookie.xml:1.9 Wed Nov 6 11:57:33 2002 +++ phpdoc/en/reference/http/functions/setcookie.xml Wed Nov 6 13:34:39 2002 @@ -1,13 +1,13 @@ -<?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.9 $ --> +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.setcookie"> <refnamediv> <refname>setcookie</refname> - <refpurpose>·¢ËÍÒ»¸ö cookie ÐÅÏ¢</refpurpose> + <refpurpose>Send a cookie</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>boolean</type><methodname>setcookie</methodname> <methodparam><type>string</type><parameter>name</parameter></methodparam> @@ -18,65 +18,81 @@ <methodparam choice="opt"><type>int</type><parameter>secure</parameter></methodparam> </methodsynopsis> <para> - <function>setcookie</function> º¯ÊýÓÃÀ´½¨Á¢Ò»¸öÐ嵀 cookie µÄÐÅÏ¢¡£ºÍÆäËüÍ·²¿ÐÅÏ¢Ò»Ñù£¬cookies - ±ØÐëÒªÊä³öÔÚÎļþµÄ<emphasis>×îÇ°Ãæ</emphasis>£¬Ò²¾ÍÒâζ×ÅÔÚÆä֮ǰ£¬Äã²»ÄÜÊä³öÈκÎ×Ö·û - (ÕâÊǹ涨)¡£°üÀ¨ - <literal><html></literal> ºÍ <literal><head></literal> - ±êÇ©ÒÔ¼°Ò»Ð©¿Õ¸ñ¡£Èç¹ûÕâЩ±êÇ©ÔÚʹÓà <function>setcookie</function> º¯ÊýǰÊä³ö£¬º¯ÊýÔËÐÐÔò»áʧ°Ü²¢·µ»Ø &false;¡£ - Ö»Òª <function>setcookie</function> º¯Êý³É¹¦ÔËÐУ¬²»¹Ü¸ÃÐÅÏ¢ÊÇ·ñ±»Óû§½ÓÊÜ£¬¶¼»á·µ»Ø &true;¡£ - </para> - <para> - ³ýÁË <parameter>name</parameter> ÒÔÍ⣬ÆäËüËùÓвÎÊý¶¼ÊÇ¿ÉÑ¡µÄ¡£Èç¹ûÖ»ÓÐ name - ²ÎÊý£¬Õ⽫»áɾ³ý¿Í»§¶ËÃû³ÆÎª name - µÄ cookie¡£µ±È»£¬ÎªÁËÌø¹ýijЩ²ÎÊýµÄÉ趨£¬Äã¿ÉÒÔΪһЩ²ÎÊý¸³¿Õ×Ö·û - (<emphasis>""</emphasis>)¡£µ«²ÎÊý - <parameter>expire</parameter> ¼° - <parameter>secure</parameter> µÄÀàÐÍÓ¦¸ÃΪÕûÊý (integers) ²¢ÇÒ²»Äܱ»¸³Îª¿Õ×Ö·û¡£Äã¿ÉÒÔÓà 0 - À´´úÌæ(<emphasis>0</emphasis>)¡£²ÎÊý - <parameter>expire</parameter> ÊÇÒ»¸ö Unix µÄʱ¼ä´Á£¬¿ÉÒÔÓà - <function>time</function> »ò <function>mktime</function> - º¯ÊýÀ´»ñµÃ¡£<parameter>secure</parameter> ²ÎÊý±íÃ÷¸Ã cookie - Ö»ÔÚ°²È« HTTP Á¬½Óϲű»·¢ËÍ¡£ - </para> - <para> - µ± cookies ±»ÉèÖú󣬱ã¿ÉÒÔÔÚÆäËüÒ³ÃæÍ¨¹ý <link linkend="reserved.variables.cookies">$_COOKIE</link> - »ò <varname>$HTTP_COOKIE_VARS</varname> Êý×éÈ¡µÃÆäÖµ¡£ÐèҪעÒâµÄÊÇ£¬<link linkend="language.variables.superglobals">autoglobals</link> - µÄ <varname>$_COOKIE</varname> ÐÎʽÊÊÓÃÓÚ PHP - <ulink url="&url.php.release4.1.0;">4.1.0</ulink> »ò¸ü¸ß°æ±¾¡£¶ø - <varname>$HTTP_COOKIE_VARS</varname> Ôò´Ó PHP 3 Æð¾Í¿ÉÒÔʹÓÃ. + <function>setcookie</function> defines a cookie to be sent along + with the rest of the HTTP headers. Like other headers, cookies + must be sent <emphasis>before</emphasis> any output from your + script (this is a protocol restriction). This requires that you + place calls to this function prior to any output, including + <literal><html></literal> and <literal><head></literal> tags + as well as any whitespace. If output exists prior to calling this + function, <function>setcookie</function> will fail and return &false;. + If <function>setcookie</function> successfully runs, it will return + &true;. This does not indicate whether the user accepted the cookie. + </para> + <para> + All the arguments except the <parameter>name</parameter> argument + are optional. If only the name argument is present, the cookie + by that name will be deleted from the remote client. You may + also replace any argument with an empty string + (<emphasis>""</emphasis>) in order to skip that + argument. The <parameter>expire</parameter> and + <parameter>secure</parameter> arguments are integers and cannot + be skipped with an empty string. Use a zero + (<emphasis>0</emphasis>) instead. The + <parameter>expire</parameter> argument is a regular Unix time + integer as returned by the <function>time</function> or + <function>mktime</function> functions. The + <parameter>secure</parameter> indicates that the cookie should + only be transmitted over a secure HTTPS connection. + </para> + <para> + Once the cookies have been set, they can be accessed on the next page load + with the <link linkend="reserved.variables.cookies">$_COOKIE</link> or + <varname>$HTTP_COOKIE_VARS</varname> arrays. Note, + <link linkend="language.variables.superglobals">autoglobals</link> + such as <varname>$_COOKIE</varname> became available in PHP + <ulink url="&url.php.release4.1.0;">4.1.0</ulink>. + <varname>$HTTP_COOKIE_VARS</varname> has existed since PHP 3. </para> <para> - ÐèҪעÒâµÄ¼¸µã: + Common Pitfalls: <itemizedlist> <listitem> <simpara> - Cookies ²»»áÔÚÄãÉèÖÃËüµÄ±¾Ò³ÉúЧ¡¢Òª²âÊÔÒ»¸ö cookie ÊÇ·ñ±»³É¹¦µÄÉ趨£¬Äã¿ÉÒÔÔÚÆäµ½ÆÚ֮ǰͨ¹ýÁíÍâÒ»¸öÒ³ÃæÀ´·ÃÎÊÆäÖµ¡£¹ýÆÚʱ¼äÊÇͨ¹ý²ÎÊý - <parameter>expire</parameter> À´ÉèÖõġ£ + Cookies will not become visible until the next loading of a page that + the cookie should be visible for. To test if a cookie was successfully + set, check for the cookie on a next loading page before the cookie + expires. Expire time is set via the <parameter>expire</parameter> + parameter. </simpara> </listitem> <listitem> <simpara> - Cookies ½«»á±»ÓëÆäͬÃûµÄºóÉ趨µÄ cookie Ëù¸²¸Ç¡£ + Cookies must be deleted with the same parameters as they were set with. </simpara> </listitem> <listitem> <simpara> - ÔÚʵ¼ÊÔËÓÃÖУ¬Äã¿ÉÒÔ°Ñ Cookies µÄÃû³ÆÉèÖóÉÒ»¸öÊý×飬µ«ÊÇÊý×é cookie ÖеÄÿ¸öÔªËØµÄÖµ½«»á±»µ¥¶À±£´æÔÚÓû§µÄϵͳÖС£Äã¿ÉÒÔÊÔ×ÅÓÃ<function>explode</function> - »ò <function>serialize</function> º¯ÊýÀ´°Ñ¶à¸ö cookie ֵдÈëµ½Ò»¸ö cookie ÎļþÖС£ + Cookies names can be set as array names and will be available to your + PHP scripts as arrays but seperate cookies are stored on the users + system. Consider <function>explode</function> or + <function>serialize</function> to set one cookie with multiple names + and values. </simpara> </listitem> </itemizedlist> </para> <simpara> - ÔÚ PHP 3 ÖУ¬ÔÚͬһ¸ö PHP ½Å±¾Öжà´ÎʹÓà <function>setcookie</function> - À´ÉèÖà cookie£¬½«»á°´ÕÕµ¹ÐòµÄ·½Ê½À´·Ö±ðÖ´ÐУ¬Èç¹ûÄãÏëÒªÔÚ²åÈëÁíÍâÒ»¸ö cookie - ǰɾ³ýÒ»¸ö cookie,Äã±ØÐëÏȲåÈëÈ»ºóÔÙɾ³ý¡£ÔÚ PHP 4 À¶à´Îµ÷Óà - <function>setcookie</function> ÔòÊǰ´ÕÕ˳ÐòÀ´Ö´Ðеġ£ + In PHP 3, multiple calls to <function>setcookie</function> in the same + script will be performed in reverse order. If you are trying to + delete one cookie before inserting another you should put the + insert before the delete. In PHP 4, multiple calls to + <function>setcookie</function> are performed in the order called. </simpara> <para> - ÏÂÃæÒ»Ð©Àý×Ó˵Ã÷ÁËÈçºÎ·¢ËÍ cookies: + Some examples follow how to send cookies: <example> - <title><function>setcookie</function> sent examples</title> + <title><function>setcookie</function> send examples</title> <programlisting role="php"> <![CDATA[ setcookie ("TestCookie", $value); @@ -87,7 +103,9 @@ </example> </para> <para> - Ò»¸ö¹ýÆÚµÄ cookie ½«»á±»×Ô¶¯É¾³ý¡£Àý×Ó˵Ã÷ÁËÈçºÎɾ³ýÒ»¸ö cookies: + When deleting a cookie you should assure that the expiration date + is in the past, to trigger the removal mechanism in your browser. + Examples follow how to delete cookies sent in previous example: <example> <title><function>setcookie</function> delete examples</title> <programlisting role="php"> @@ -100,7 +118,11 @@ </example> </para> <para> - ҪעÒâµÄÊÇ cookie µÄÖµÔÚ·¢Ë͵Äʱºò»á±»×Ô¶¯µÄ±àÂë²¢±£´æ£¬¶øµ±Äã¶ÁÈ¡ËüµÄʱºò£¬ËüÓֻᱻ×Ô¶¯µÄ½âÂë²¢×Ô¶¯°Ñ×Ô¼º¸³Öµ¸øÓë×Ô¼ºÍ¬ÃûµÄÒ»¸ö±äÁ¿¡£Äã¿ÉÒÔͨ¹ýÏÂÃæ¼òµ¥µÄÀý×ÓÀ´¿´µ½: + Note that the value portion of the cookie will automatically be + urlencoded when you send the cookie, and when it is received, it + is automatically decoded and assigned to a variable by the same + name as the cookie name. To see the contents of our test + cookie in a script, simply use one of the following examples: <informalexample> <programlisting role="php"> <![CDATA[ @@ -111,8 +133,11 @@ </informalexample> </para> <para> - ÄãÒ²¿ÉÒÔÉèÖÃÒ»¸öÊý×éÀ´´æ·Å cookie£¬°ÑÐí¶àÃû³Æ²»Í¬µÄ cookie ·Åµ½Ò»¸öÊý×éÖдæ·Å¡£ÕâÑùÄãÔÚ½ÓÊÕ cookie - µÄʱºòÖ»ÐèÒªÒª»ñȡһ¸öÊý×é: + You may also set array cookies by using array notation in the + cookie name. This has the effect of setting as many cookies as + you have array elements, but when the cookie is received by your + script, the values are all placed in an array with the cookie's + name: <informalexample> <programlisting role="php"> <![CDATA[ @@ -129,11 +154,19 @@ </informalexample> </para> <para> - ¹ØÓÚ cookies ¸ü¶àµÄ½éÉÜ£¬¿ÉÒԲο¼Íø¾°¹«Ë¾µÄ cookies ˵Ã÷Êé - <ulink url="&spec.cookies;">&spec.cookies;</ulink>. + For more information on cookies, see Netscape's cookie + specification at <ulink + url="&spec.cookies;">&spec.cookies;</ulink>. </para> <simpara> - Netscape Communicator 4.05 ¼° Microsoft Internet Explorer 3.x ÔÚ cookie µÄ·¾¶ºÍʱ¼äûÓÐÉèÖõÄÇé¿öÏ»á³öÏÖһЩÎÊÌâ¡£ + Microsoft Internet Explorer 4 with Service Pack 1 applied does + not correctly deal with cookies that have their path parameter + set. + </simpara> + <simpara> + Netscape Communicator 4.05 and Microsoft Internet Explorer 3.x + appear to handle cookies incorrectly when the path and time + are not set. </simpara> </refsect1> </refentry>
Index: phpdoc/en/reference/http/reference.xml diff -u phpdoc/en/reference/http/reference.xml:1.5 phpdoc/en/reference/http/reference.xml:1.6 --- phpdoc/en/reference/http/reference.xml:1.5 Wed Nov 6 11:21:38 2002 +++ phpdoc/en/reference/http/reference.xml Wed Nov 6 13:34:39 2002 @@ -1,14 +1,15 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <reference id="ref.http"> - <title>HTTP Ïà¹Øº¯Êý</title> + <title>HTTP functions</title> <titleabbrev>HTTP</titleabbrev> <partintro> <section id="http.intro"> &reftitle.intro; <para> - ÕâЩº¯Êý¿ÉÒÔÈÃÄãÒÀ¾Ý HTTP ±ê×¼ÐÒéÏò¿Í»§¶Ëä¯ÀÀÆ÷·¢ËÍÍ·²¿ÐÅÏ¢¡£ + These functions let you manipulate the output sent back to the + remote browser right down to the HTTP protocol level. </para> </section> Index: phpdoc/en/reference/http/functions/header.xml diff -u phpdoc/en/reference/http/functions/header.xml:1.7 phpdoc/en/reference/http/functions/header.xml:1.8 --- phpdoc/en/reference/http/functions/header.xml:1.7 Wed Nov 6 11:21:40 2002 +++ phpdoc/en/reference/http/functions/header.xml Wed Nov 6 13:34:39 2002 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.header"> <refnamediv> <refname>header</refname> - <refpurpose>Ïòä¯ÀÀÆ÷·¢ËÍÒ»¸ö HTTP Í·²¿ÐÅÏ¢</refpurpose> + <refpurpose>Send a raw HTTP header</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>int</type><methodname>header</methodname> <methodparam><type>string</type><parameter>string</parameter></methodparam> @@ -15,14 +15,17 @@ <methodparam choice="opt"><type>int</type><parameter>http_reponse_code</parameter></methodparam> </methodsynopsis> <para> - <function>header</function> º¯ÊýÓÃÀ´·¢ËÍÒ»¸ö <acronym>HTTP</acronym> - Í·²¿ÐÅÏ¢µ½¿Í»§¶ËµÄä¯ÀÀÆ÷¡£ÓÐ¹Ø <acronym>HTTP</acronym> Í·²¿ÐÅÏ¢µÄ¸ü¶àÄÚÈݲμû¹Ù·½Îĵµ - <ulink url="&spec.http1.1;">HTTP/1.1 specification</ulink>¡£ + <function>header</function> is used to send raw + <acronym>HTTP</acronym> headers. See the <ulink + url="&spec.http1.1;">HTTP/1.1 specification</ulink> for more + information on <acronym>HTTP</acronym> headers. </para> <para> - ¿ÉÑ¡²ÎÊý <parameter>replace</parameter> - ÓÃÀ´±íʾµ±³öÏÖÁ½¸öÏàËÆµÄÍ·²¿ÐÅϢʱ£¬ÊÇÌæ»»Ç°Ò»¸öÏàͬµÄÍ·²¿ÐÅÏ¢»¹ÊÇÔö¼ÓÒ»¸öÏàͬµÄÍ·²¿ÐÅÏ¢¡£Ä¬ÈÏÎªÌæ»»£¬Èç¹ûÄ㽫ÆäÉèΪ - &false; Ôò¿ÉÒÔ¶à´Î·¢ËÍÏàͬµÄÍ·²¿ÐÅÏ¢¡£ÀýÈç: + The optional <parameter>replace</parameter> parameter indicates + whether the header should replace a previous similar header, or + add a second header of the same type. By default it will replace, + but if you pass in &false; as the second argument you can force + multiple headers of the same type. For example: <informalexample> <programlisting role="php"> <![CDATA[ @@ -35,12 +38,15 @@ </informalexample> </para> <para> - µÚ¶þ¸ö¿ÉÑ¡²ÎÊý <parameter>http_response_code</parameter> ±íʾ HTTP - µÄÍ·²¿ÐÅÏ¢µÄ´úÂë¡£(´Ë²ÎÊýÔÚPHP 4.3.0 ±»¼ÓÈë¡£) + The second optional <parameter>http_response_code</parameter> force the + HTTP response code to the specified value. (This parameter is available + in PHP 4.3.0 and higher.) </para> <para> - Í·²¿ÐÅÏ¢µÄ¸ñʽÓÐÁ½ÖÖÐÎʽ¡£Ò»ÖÖÇé¿öÊÇÒÔ×Ö·û ¡°<literal>HTTP/</literal>¡± (²»Çø·Ö´óСд)¿ªÍ·µÄ£¬which will be used to figure out the HTTP status - code to send¡£ÀýÈç,Èç¹ûÄãif you have configured Apache to + There are two special-case header calls. The first is a header + that starts with the string "<literal>HTTP/</literal>" (case is not + significant), which will be used to figure out the HTTP status + code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the <literal>ErrorDocument</literal> directive), you may want to make sure that your script generates the proper status code. @@ -55,7 +61,6 @@ </informalexample> <note> <para> - HTTP Í·²¿ÐÅÏ¢¾³£Ê×Ïȱ»·¢Ë͵½¿Í»§¶Ë£¬ The HTTP status header line will always be the first sent to the client, regardless of the actual <function>header</function> call beeing the first or not. The status may be overridden @@ -65,8 +70,9 @@ </note> <note> <para> - ÔÚ PHP 3 ÖУ¬´Ëº¯ÊýÖ»ÔÚ PHP ÒÔ Apache µÄÄ£¿é»¯ÔËÐеÄʱºòÓÐЧ¡£Äã¿ÉÒÔʹÓà <literal>Status</literal> - À´´ïµ½ÏàͬµÄЧ¹û¡£ + In PHP 3, this only works when PHP is compiled as an Apache + module. You can achieve the same effect using the + <literal>Status</literal> header. <informalexample> <programlisting role="php"> <![CDATA[ @@ -80,7 +86,7 @@ </note> </para> <para> - µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£Not only does + The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a <literal>REDIRECT</literal> (302) status code to the browser unless some <literal>3xx</literal> status code has already been set. @@ -98,11 +104,13 @@ </para> <note> <para> - HTTP/1.1 ±ê×¼ÐèÒªÒ»¸ö¾ø¶ÔµØÖ·µÄ <acronym>URI</acronym> ×öΪ + HTTP/1.1 requires an absolute <acronym>URI</acronym> as argument to <ulink url="&spec.http1.1;-sec14.html#sec14.30">Location:</ulink> - µÄ²ÎÊý, µ«ÓÐһЩ¿Í»§¶ËÖ§³ÖÐéÄâµÄ·¾¶¡£Äãͨ³£¿ÉÒÔʹÓà - <literal>$_SERVER['HTTP_HOST']</literal>¡¢<literal>$_SERVER['PHP_SELF']</literal> - ¼° <function>dirname</function> º¯ÊýÀ´×Ô¼º»ñÈ¡ËùÐèÒªµÄ¾ø¶Ô·¾¶: + including the scheme, hostname and absolute path, but + some clients accept relative URIs. You can usually use + <literal>$_SERVER['HTTP_HOST']</literal>, <literal>$_SERVER['PHP_SELF']</literal> + and <function>dirname</function> to make an absolute URI from a + relative one yourself: <informalexample> <programlisting> <![CDATA[ @@ -117,8 +125,11 @@ </para> </note> <para> - PHP ½Å±¾Í¨³£ÊǶ¯Ì¬¸Ä±äµÄ¡£¿ÉÓÐЩ¿Í»§¶Ë»òһЩ´úÀí·þÎñÆ÷»á°ÑһЩä¯ÀÀ¹ýµÄÄÚÈݸø»º³åÆðÀ´£¬ÕâÑùÄú¸üеĽű¾¾Í²»Äܱ»¿Í»§¶Ë¼°Ê±µÄ·¢ÏÖ£¬Äã¿ÉÒÔͨ¹ý·¢ËÍһЩÀàËÆÏÂÃæÀý×ÓÖеÄÍ·²¿ÐÅÏ¢À´½ûÖ¹ËûÃÇ»º´æÄãµÄÍøÒ³¡£ - <informalexample> + PHP scripts often generate dynamic content that must not be cached + by the client browser or any proxy caches between the server and the + client browser. Many proxies and clients can be forced to disable + caching with + <informalexample> <programlisting role="php"> <![CDATA[ <?php @@ -134,15 +145,16 @@ </informalexample> <note> <para> - Äã¿ÉÄܻᷢÏÖ¼´Ê¹ÄãûÓаÑÉϱߵĴúÂëÈ«²¿Êä³öÄãµÄÍøÒ³Ò²Ã»Óб»»º³åÆðÀ´¡£ÕâÊÇÒòΪһЩÓû§ÔÚËûÃǵÄä¯ÀÀÆ÷µÄÉèÖÃThere are a number of options + You may find that your pages aren't cached even if you don't + output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached. </para> <para> - ÁíÍ⣬<function>session_cache_limiter</function> ºÍ - <literal>session.cache_limiter</literal> configuration + Additionally, <function>session_cache_limiter</function> and + the <literal>session.cache_limiter</literal> configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used. </para> Index: phpdoc/en/reference/http/functions/headers-sent.xml diff -u phpdoc/en/reference/http/functions/headers-sent.xml:1.5 phpdoc/en/reference/http/functions/headers-sent.xml:1.6 --- phpdoc/en/reference/http/functions/headers-sent.xml:1.5 Wed Nov 6 11:19:55 2002 +++ phpdoc/en/reference/http/functions/headers-sent.xml Wed Nov 6 13:34:39 2002 @@ -1,35 +1,39 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.7 --> <refentry id="function.headers-sent"> <refnamediv> <refname>headers_sent</refname> - <refpurpose>²âÊÔÍ·²¿ÐÅÏ¢ÊÇ·ñÒѾ±»·¢ËÍ£¬Èç¹ûÊÇ£¬·µ»Ø &true;</refpurpose> + <refpurpose>Returns &true; if headers have been sent</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>bool</type><methodname>headers_sent</methodname> <methodparam><type>string</type><parameter>&file</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>&line</parameter></methodparam> </methodsynopsis> <para> - Õâ¸öº¯Êý²âÊԽű¾ÖÐÍ·²¿ÐÅÏ¢ÊÇ·ñÒѾ·¢ËÍ£¬Èç¹ûÊÇÔò·µ»Ø &true; ·ñÔò·µ»Ø &false;¡£Ò»µ©Í·²¿ÐÅÏ¢ÒѾ±»·¢ËÍ£¬Ä㽫²»ÄÜÔÙʹÓà <function>header</function> - º¯ÊýÀ´·¢ËÍÆäËüµÄÍ·²¿ÐÅÏ¢¡£Ê¹Óô˺¯Êý¿ÉÒÔʹÄã×î´óÏ޶ȵıÜÃâÀàËÆ "Duplicate headers ..." µÄ´íÎóÐÅÏ¢¡£ + This function returns &true; if the HTTP headers have already been + sent, &false; otherwise. You can't add any more header lines using + the <function>header</function> function once the header block has + already been sent. Using this function you can at least prevent + getting the "Duplicate headers ..." error messages. </para> <para> - Èç¹û¿ÉÏȲÎÊý <parameter>file</parameter> - ¼° <parameter>line</parameter> - ±»Ö¸¶¨£¬Ôòº¯Êý»á·µ»ØÖ¸¶¨ÎļþÖ¸¶¨ÐÐÊýÆðÍ·²¿ÐÅÏ¢µÄ·¢ËÍÇé¿ö¡£ + The function will return the php source file and line number where + output started in the optional <parameter>file</parameter> and + <parameter>line</parameter> parameters if these are given. </para> <note> <simpara> - <parameter>file</parameter> and <parameter>line</parameter> - ²ÎÊýÔÚ PHP 4.3.0 °æ±¾Öб»¼ÓÈë¡£ + <parameter>file</parameter> and <parameter>line</parameter> where + added for PHP 4.3.0. </simpara> </note> <para> - ¸ü¶àϸ½ÚµÄÌÖÂ۲μû <function>header</function>¡£ + See also <function>header</function> for a more detailed discussion + of the matters involved. </para> </refsect1> </refentry> Index: phpdoc/en/reference/http/functions/setcookie.xml diff -u phpdoc/en/reference/http/functions/setcookie.xml:1.9 phpdoc/en/reference/http/functions/setcookie.xml:1.10 --- phpdoc/en/reference/http/functions/setcookie.xml:1.9 Wed Nov 6 11:57:33 2002 +++ phpdoc/en/reference/http/functions/setcookie.xml Wed Nov 6 13:34:39 2002 @@ -1,13 +1,13 @@ -<?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.9 $ --> +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.setcookie"> <refnamediv> <refname>setcookie</refname> - <refpurpose>·¢ËÍÒ»¸ö cookie ÐÅÏ¢</refpurpose> + <refpurpose>Send a cookie</refpurpose> </refnamediv> <refsect1> - <title>ÃèÊö</title> + <title>Description</title> <methodsynopsis> <type>boolean</type><methodname>setcookie</methodname> <methodparam><type>string</type><parameter>name</parameter></methodparam> @@ -18,65 +18,81 @@ <methodparam choice="opt"><type>int</type><parameter>secure</parameter></methodparam> </methodsynopsis> <para> - <function>setcookie</function> º¯ÊýÓÃÀ´½¨Á¢Ò»¸öÐ嵀 cookie µÄÐÅÏ¢¡£ºÍÆäËüÍ·²¿ÐÅÏ¢Ò»Ñù£¬cookies - ±ØÐëÒªÊä³öÔÚÎļþµÄ<emphasis>×îÇ°Ãæ</emphasis>£¬Ò²¾ÍÒâζ×ÅÔÚÆä֮ǰ£¬Äã²»ÄÜÊä³öÈκÎ×Ö·û - (ÕâÊǹ涨)¡£°üÀ¨ - <literal><html></literal> ºÍ <literal><head></literal> - ±êÇ©ÒÔ¼°Ò»Ð©¿Õ¸ñ¡£Èç¹ûÕâЩ±êÇ©ÔÚʹÓà <function>setcookie</function> º¯ÊýǰÊä³ö£¬º¯ÊýÔËÐÐÔò»áʧ°Ü²¢·µ»Ø &false;¡£ - Ö»Òª <function>setcookie</function> º¯Êý³É¹¦ÔËÐУ¬²»¹Ü¸ÃÐÅÏ¢ÊÇ·ñ±»Óû§½ÓÊÜ£¬¶¼»á·µ»Ø &true;¡£ - </para> - <para> - ³ýÁË <parameter>name</parameter> ÒÔÍ⣬ÆäËüËùÓвÎÊý¶¼ÊÇ¿ÉÑ¡µÄ¡£Èç¹ûÖ»ÓÐ name - ²ÎÊý£¬Õ⽫»áɾ³ý¿Í»§¶ËÃû³ÆÎª name - µÄ cookie¡£µ±È»£¬ÎªÁËÌø¹ýijЩ²ÎÊýµÄÉ趨£¬Äã¿ÉÒÔΪһЩ²ÎÊý¸³¿Õ×Ö·û - (<emphasis>""</emphasis>)¡£µ«²ÎÊý - <parameter>expire</parameter> ¼° - <parameter>secure</parameter> µÄÀàÐÍÓ¦¸ÃΪÕûÊý (integers) ²¢ÇÒ²»Äܱ»¸³Îª¿Õ×Ö·û¡£Äã¿ÉÒÔÓà 0 - À´´úÌæ(<emphasis>0</emphasis>)¡£²ÎÊý - <parameter>expire</parameter> ÊÇÒ»¸ö Unix µÄʱ¼ä´Á£¬¿ÉÒÔÓà - <function>time</function> »ò <function>mktime</function> - º¯ÊýÀ´»ñµÃ¡£<parameter>secure</parameter> ²ÎÊý±íÃ÷¸Ã cookie - Ö»ÔÚ°²È« HTTP Á¬½Óϲű»·¢ËÍ¡£ - </para> - <para> - µ± cookies ±»ÉèÖú󣬱ã¿ÉÒÔÔÚÆäËüÒ³ÃæÍ¨¹ý <link linkend="reserved.variables.cookies">$_COOKIE</link> - »ò <varname>$HTTP_COOKIE_VARS</varname> Êý×éÈ¡µÃÆäÖµ¡£ÐèҪעÒâµÄÊÇ£¬<link linkend="language.variables.superglobals">autoglobals</link> - µÄ <varname>$_COOKIE</varname> ÐÎʽÊÊÓÃÓÚ PHP - <ulink url="&url.php.release4.1.0;">4.1.0</ulink> »ò¸ü¸ß°æ±¾¡£¶ø - <varname>$HTTP_COOKIE_VARS</varname> Ôò´Ó PHP 3 Æð¾Í¿ÉÒÔʹÓÃ. + <function>setcookie</function> defines a cookie to be sent along + with the rest of the HTTP headers. Like other headers, cookies + must be sent <emphasis>before</emphasis> any output from your + script (this is a protocol restriction). This requires that you + place calls to this function prior to any output, including + <literal><html></literal> and <literal><head></literal> tags + as well as any whitespace. If output exists prior to calling this + function, <function>setcookie</function> will fail and return &false;. + If <function>setcookie</function> successfully runs, it will return + &true;. This does not indicate whether the user accepted the cookie. + </para> + <para> + All the arguments except the <parameter>name</parameter> argument + are optional. If only the name argument is present, the cookie + by that name will be deleted from the remote client. You may + also replace any argument with an empty string + (<emphasis>""</emphasis>) in order to skip that + argument. The <parameter>expire</parameter> and + <parameter>secure</parameter> arguments are integers and cannot + be skipped with an empty string. Use a zero + (<emphasis>0</emphasis>) instead. The + <parameter>expire</parameter> argument is a regular Unix time + integer as returned by the <function>time</function> or + <function>mktime</function> functions. The + <parameter>secure</parameter> indicates that the cookie should + only be transmitted over a secure HTTPS connection. + </para> + <para> + Once the cookies have been set, they can be accessed on the next page load + with the <link linkend="reserved.variables.cookies">$_COOKIE</link> or + <varname>$HTTP_COOKIE_VARS</varname> arrays. Note, + <link linkend="language.variables.superglobals">autoglobals</link> + such as <varname>$_COOKIE</varname> became available in PHP + <ulink url="&url.php.release4.1.0;">4.1.0</ulink>. + <varname>$HTTP_COOKIE_VARS</varname> has existed since PHP 3. </para> <para> - ÐèҪעÒâµÄ¼¸µã: + Common Pitfalls: <itemizedlist> <listitem> <simpara> - Cookies ²»»áÔÚÄãÉèÖÃËüµÄ±¾Ò³ÉúЧ¡¢Òª²âÊÔÒ»¸ö cookie ÊÇ·ñ±»³É¹¦µÄÉ趨£¬Äã¿ÉÒÔÔÚÆäµ½ÆÚ֮ǰͨ¹ýÁíÍâÒ»¸öÒ³ÃæÀ´·ÃÎÊÆäÖµ¡£¹ýÆÚʱ¼äÊÇͨ¹ý²ÎÊý - <parameter>expire</parameter> À´ÉèÖõġ£ + Cookies will not become visible until the next loading of a page that + the cookie should be visible for. To test if a cookie was successfully + set, check for the cookie on a next loading page before the cookie + expires. Expire time is set via the <parameter>expire</parameter> + parameter. </simpara> </listitem> <listitem> <simpara> - Cookies ½«»á±»ÓëÆäͬÃûµÄºóÉ趨µÄ cookie Ëù¸²¸Ç¡£ + Cookies must be deleted with the same parameters as they were set with. </simpara> </listitem> <listitem> <simpara> - ÔÚʵ¼ÊÔËÓÃÖУ¬Äã¿ÉÒÔ°Ñ Cookies µÄÃû³ÆÉèÖóÉÒ»¸öÊý×飬µ«ÊÇÊý×é cookie ÖеÄÿ¸öÔªËØµÄÖµ½«»á±»µ¥¶À±£´æÔÚÓû§µÄϵͳÖС£Äã¿ÉÒÔÊÔ×ÅÓÃ<function>explode</function> - »ò <function>serialize</function> º¯ÊýÀ´°Ñ¶à¸ö cookie ֵдÈëµ½Ò»¸ö cookie ÎļþÖС£ + Cookies names can be set as array names and will be available to your + PHP scripts as arrays but seperate cookies are stored on the users + system. Consider <function>explode</function> or + <function>serialize</function> to set one cookie with multiple names + and values. </simpara> </listitem> </itemizedlist> </para> <simpara> - ÔÚ PHP 3 ÖУ¬ÔÚͬһ¸ö PHP ½Å±¾Öжà´ÎʹÓà <function>setcookie</function> - À´ÉèÖà cookie£¬½«»á°´ÕÕµ¹ÐòµÄ·½Ê½À´·Ö±ðÖ´ÐУ¬Èç¹ûÄãÏëÒªÔÚ²åÈëÁíÍâÒ»¸ö cookie - ǰɾ³ýÒ»¸ö cookie,Äã±ØÐëÏȲåÈëÈ»ºóÔÙɾ³ý¡£ÔÚ PHP 4 À¶à´Îµ÷Óà - <function>setcookie</function> ÔòÊǰ´ÕÕ˳ÐòÀ´Ö´Ðеġ£ + In PHP 3, multiple calls to <function>setcookie</function> in the same + script will be performed in reverse order. If you are trying to + delete one cookie before inserting another you should put the + insert before the delete. In PHP 4, multiple calls to + <function>setcookie</function> are performed in the order called. </simpara> <para> - ÏÂÃæÒ»Ð©Àý×Ó˵Ã÷ÁËÈçºÎ·¢ËÍ cookies: + Some examples follow how to send cookies: <example> - <title><function>setcookie</function> sent examples</title> + <title><function>setcookie</function> send examples</title> <programlisting role="php"> <![CDATA[ setcookie ("TestCookie", $value); @@ -87,7 +103,9 @@ </example> </para> <para> - Ò»¸ö¹ýÆÚµÄ cookie ½«»á±»×Ô¶¯É¾³ý¡£Àý×Ó˵Ã÷ÁËÈçºÎɾ³ýÒ»¸ö cookies: + When deleting a cookie you should assure that the expiration date + is in the past, to trigger the removal mechanism in your browser. + Examples follow how to delete cookies sent in previous example: <example> <title><function>setcookie</function> delete examples</title> <programlisting role="php"> @@ -100,7 +118,11 @@ </example> </para> <para> - ҪעÒâµÄÊÇ cookie µÄÖµÔÚ·¢Ë͵Äʱºò»á±»×Ô¶¯µÄ±àÂë²¢±£´æ£¬¶øµ±Äã¶ÁÈ¡ËüµÄʱºò£¬ËüÓֻᱻ×Ô¶¯µÄ½âÂë²¢×Ô¶¯°Ñ×Ô¼º¸³Öµ¸øÓë×Ô¼ºÍ¬ÃûµÄÒ»¸ö±äÁ¿¡£Äã¿ÉÒÔͨ¹ýÏÂÃæ¼òµ¥µÄÀý×ÓÀ´¿´µ½: + Note that the value portion of the cookie will automatically be + urlencoded when you send the cookie, and when it is received, it + is automatically decoded and assigned to a variable by the same + name as the cookie name. To see the contents of our test + cookie in a script, simply use one of the following examples: <informalexample> <programlisting role="php"> <![CDATA[ @@ -111,8 +133,11 @@ </informalexample> </para> <para> - ÄãÒ²¿ÉÒÔÉèÖÃÒ»¸öÊý×éÀ´´æ·Å cookie£¬°ÑÐí¶àÃû³Æ²»Í¬µÄ cookie ·Åµ½Ò»¸öÊý×éÖдæ·Å¡£ÕâÑùÄãÔÚ½ÓÊÕ cookie - µÄʱºòÖ»ÐèÒªÒª»ñȡһ¸öÊý×é: + You may also set array cookies by using array notation in the + cookie name. This has the effect of setting as many cookies as + you have array elements, but when the cookie is received by your + script, the values are all placed in an array with the cookie's + name: <informalexample> <programlisting role="php"> <![CDATA[ @@ -129,11 +154,19 @@ </informalexample> </para> <para> - ¹ØÓÚ cookies ¸ü¶àµÄ½éÉÜ£¬¿ÉÒԲο¼Íø¾°¹«Ë¾µÄ cookies ˵Ã÷Êé - <ulink url="&spec.cookies;">&spec.cookies;</ulink>. + For more information on cookies, see Netscape's cookie + specification at <ulink + url="&spec.cookies;">&spec.cookies;</ulink>. </para> <simpara> - Netscape Communicator 4.05 ¼° Microsoft Internet Explorer 3.x ÔÚ cookie µÄ·¾¶ºÍʱ¼äûÓÐÉèÖõÄÇé¿öÏ»á³öÏÖһЩÎÊÌâ¡£ + Microsoft Internet Explorer 4 with Service Pack 1 applied does + not correctly deal with cookies that have their path parameter + set. + </simpara> + <simpara> + Netscape Communicator 4.05 and Microsoft Internet Explorer 3.x + appear to handle cookies incorrectly when the path and time + are not set. </simpara> </refsect1> </refentry>