cvs: phpdoc-zh /reference/http/function header.xml
| From: | Chen bole | Date: | Fri, 08 Nov 2002 06:15:21 +0000 |
| Subject: | cvs: phpdoc-zh /reference/http/function header.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-812@lists.php.net to get a copy of this message | ||
avenger Fri Nov 8 01:15:21 2002 EDT
Modified files:
/phpdoc-zh/reference/http/function header.xml
Log:
add head info and finished
Index: phpdoc-zh/reference/http/function/header.xml diff -u phpdoc-zh/reference/http/function/header.xml:1.1 phpdoc-zh/reference/http/function/header.xml:1.2 --- phpdoc-zh/reference/http/function/header.xml:1.1 Thu Nov 7 00:49:58 2002 +++ phpdoc-zh/reference/http/function/header.xml Fri Nov 8 01:15:21 2002 @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: avenger $ --> +<!-- EN-Revision: 1.8 Maintainer: Avenger Status: working --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.header"> <refnamediv> @@ -40,10 +42,8 @@ </para> <para> Í·²¿ÐÅÏ¢µÄ¸ñʽÓÐÁ½ÖÖÐÎʽ¡£Ò»ÖÖÇé¿öÊÇÒÔ×Ö·û ¡°<literal>HTTP/</literal>¡± (²»Çø·Ö´óСд)¿ªÍ·µÄ£¬which will be used to figure out the HTTP status - code to send¡£ÀýÈç,Èç¹ûÄã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. + code to send¡£ÀýÈç,Èç¹ûÄãʹÓÃµÄ WEB ·þÎñÆ÷ÊÇ Apache µÄ»°£¬Èç¹ûÒªÖÆ×÷Ò»¸öÕÒ²»µ½ÎÄÕµĴíÎó´¦ÀíÒ³Ãæ + (ʹÓà <literal>ErrorDocument</literal> Ö¸Áî)£¬Äã¿ÉÄÜ»áÐèÒªÓÃËüÀ´²úÉúһЩÊʵ±µÄ״̬´úÂë¡£ <informalexample> <programlisting role="php"> <![CDATA[ @@ -55,12 +55,11 @@ </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 + HTTP Í·²¿ÐÅϢͨ³£ÊÇÊ×Ïȱ»·¢Ë͵½¿Í»§¶ËµÄ£¬Ëü²¢²»¹ÜÄãµÄ <function>header</function> + º¯ÊýÊÇ·ñÊÇÔÚµÚÒ»ÐС£ÔÚͨ³£µÄÇé¿öÏÂThe status may be overridden by calling <function>header</function> with a new status line at any time unless the HTTP headers have already been sent. + ³ý·Ç HTTP Í·²¿ÐÅÏ¢ÒѾ±»·¢ËÍ¡£ </para> </note> <note> @@ -80,10 +79,8 @@ </note> </para> <para> - µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£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. + µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£Ëü²»Ö»ÊǼòµ¥µÄÏòä¯ÀÀÆ÷·¢ËÍһЩͷ²¿ÐÅÏ¢£¬Í¨³£Ëü»áÏòä¯ÀÀÆ÷·¢ËͳöÒ»¸ö <literal>REDIRECT</literal> + (302) (Ìø×ª) ״̬´úÂ룬³ý·ÇһЩÀàËÆÓÚ <literal>3xx</literal> µÄ״̬´úÂëÒѾ±»·¢ËÍ¡£ <informalexample> <programlisting role="php"> <![CDATA[ @@ -134,67 +131,50 @@ </informalexample> <note> <para> - Äã¿ÉÄܻᷢÏÖ¼´Ê¹ÄãûÓаÑÉϱߵĴúÂëÈ«²¿Êä³öÄãµÄÍøÒ³Ò²Ã»Óб»»º³åÆðÀ´¡£ÕâÊÇÒòΪһЩÓû§ÔÚËûÃǵÄä¯ÀÀÆ÷µÄÉèÖÃ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 - setting can be used to automatically generate the correct - caching-related headers when sessions are being used. + ÁíÍ⣬µ± session ÔÚ´úÂëÖб»Ê¹ÓÃʱ£¬ÀûÓà <function>session_cache_limiter</function> º¯ÊýºÍ + <literal>session.cache_limiter</literal> Ñ¡Ïî¿ÉÒÔ×Ô¶¯µÄ²úÉúÏà¹ØµÄ»º³åÇø¡£ </para> </note> </para> <para> - Remember that <function>header</function> must be - called before any actual output is sent, either by normal HTML - tags, blank lines in a file, or from PHP. It is a very common - error to read code with <function>include</function>, or - <function>require</function>, functions, or another file access - function, and have spaces or empty lines that are output before - <function>header</function> is called. The same problem exists - when using a single PHP/HTML file. + ÒªÀÎ¼Ç <function>header</function> + ҪʹÓÃÔÚÈκÎÍøÒ³Êä³öǰ¡£°üÀ¨Ò»Ð©·Ç HTML ±êÇ©ºÍ¿ÕÐж¼²»ÔÊÐíÔÚÆä֮ǰÊä³ö¡£ÔÚʹÓà <function>include</function> + ¡¢<function>require</function> º¯Êý»òһЩÆäËüµÄÎļþ´æÈ¡ÀຯÊýʱ£¬ÕâÊÇÒ»¸öºÜ³£·¸µÄ´íÎó¡£Í¬ÑùÔÚÒ»¸öµ¥¶ÀµÄ PHP/HTML + ÎļþÖÐÕâ¸ö´íÎóÒ²ºÜÆÕ±é¡£ <informalexample> <programlisting role="php"> <![CDATA[ <?php header ("Content-type: audio/x-pn-realaudio"); ?> -// Broken, note the blank line above +// ³ö´í£¬×¢Òâ header ǰµÄ¿Õ¸ñ ]]> </programlisting> </informalexample> <note> <para> - In PHP 4, you can use output buffering to get around this problem, - with the overhead of all of your output to the browser being buffered - in the server until you send it. You can do this by calling - <function>ob_start</function> and <function>ob_end_flush</function> - in your script, or setting the <literal>output_buffering</literal> - configuration directive on in your &php.ini; or - server configuration files. + ÔÚ PHP 4ÀÄã¿ÉÒÔͨ¹ýһЩÊä³ö»º³åº¯ÊýÀ´½â¾öÕâ¸öÎÊÌâ¡£ÕâÑù×ö£¬Äã¿ÉÒÔ°ÑËùÓеÄÊä³ö¶¼»º³åµ½·þÎñ£¬Ö±µ½ÄãÏÂÃüÁî·¢ËÍËüÃÇ¡£Äã¿ÉÒÔÔÚÄãµÄ´úÂëÖÐʹÓà <function>ob_start</function> ¼° <function>ob_end_flush</function> + À´ÊµÏÖÕâÑùµÄ¹¦ÄÜ£¬»òÕßͨ¹ýÐÞ¸ÄÄãµÄ &php.ini; ÖÐµÄ <literal>output_buffering</literal> + Ñ¡ÏîÀ´ÊµÏÖ£¬Ò²¿ÉÒÔͨ¹ýÐÞ¸ÄÄãµÄ·þÎñÆ÷ÅäÖÃÎļþÀ´ÊµÏÖ¡£ </para> </note> </para> <para> - If you want the user to be prompted to save the data you are - sending, such as a generated PDF file, you can use the <ulink - url="&url.rfc2183;">Content-Disposition</ulink> header to - supply a recommended filename and force the browser to display the - save dialog. + Èç¹ûÄãÏëÌáʾÓû§ÏÂÔØ²¢±£´æÒ»¸öÎļþ£¬ÀýÈçÒ»¸ö PDF + Îļþ£¬Äã¿ÉÒÔͨ¹ý·¢ËÍ <ulink url="&url.rfc2183;">Content-Disposition</ulink> ÐÅÏ¢À´Ê¹¿Í»§¶Ë»úÆ÷µ¯³öÏÂÔØ¶Ô»°¿òÀ´ÏÂÔØÄúÐèÒª´¦ÀíµÄÎļþ¡£ <informalexample> <programlisting role="php"> <![CDATA[ <?php -// We'll be outputting a PDF +// ÕâÑù½«»áÖ±½ÓÊä³öÒ»¸ö PDF Îļþ header("Content-type: application/pdf"); -// It will be called downloaded.pdf +// ÕâÑù×ö¾Í»áÌáʾÏÂÔØ PDF Îļþ downloaded.pdf header("Content-Disposition: attachment; filename=downloaded.pdf"); -// The PDF source is in original.pdf +// ÕâÊÇ original.pdf µÄÔ´Îļþ readfile('original.pdf'); ?> ]]> @@ -202,25 +182,22 @@ </informalexample> <note> <para> - There is a bug in Microsoft Internet Explorer 4.01 that prevents - this from working. There is no workaround. There is also a bug - in Microsoft Internet Explorer 5.5 that interferes with this, - which can be resolved by upgrading to Service Pack 2 or later. + Microsoft Internet Explorer 4.01 ÖеÄÒ»¸ö©¶´Ê¹µÃ¸Ã»úÖÆÎÞ·¨Õý³£¹¤×÷¡£ÔÚ Microsoft Internet Explorer 5 + ÖÐÕâ¸ö©¶´ÒÀÈ»´æÔÚ£¬Éý¼¶ Service Pack 2 ¼°ÆäÒÔºó°æ±¾ÖÐÕâ¸ö©¶´½«²»¸´´æÔÚ¡£ </para> </note> </para> <note> <simpara> - If <link linkend="ini.safe-mode">safe mode</link> is enabled the - uid of the script is added to the <literal>realm</literal> part - of the <literal>WWW-Authenticate</literal> header if you set - this header (used for HTTP Authentication). + Èç¹û PHP ÔËÐÐÔÚ°²È«Ä£Ê½ (<link linkend="ini.safe-mode">safe mode</link>) + Ï£¬µ±Ç°Ê¹ÓÃÕߵıêʶºÅ (UID) »á¸½¼Óµ½Í·²¿ÐÅÏ¢ <literal>WWW-Authenticate</literal> + µÄ <literal>realm</literal> ²¿·ÖÒ»Æð·¢ËÍ¡£(¿ÉÒÔÓÃÀ´×ö HTTP ÈÏÖ¤)¡£ </simpara> </note> <para> - See also <function>headers_sent</function>, - <function>setcookie</function>, and the section on - <link linkend="features.http-auth">HTTP authentication</link>. + ²Î¼û <function>headers_sent</function>, + <function>setcookie</function> + ¼° <link linkend="features.http-auth">HTTP authentication</link> Õ½Ú. </para> </refsect1> </refentry>
Index: phpdoc-zh/reference/http/function/header.xml diff -u phpdoc-zh/reference/http/function/header.xml:1.1 phpdoc-zh/reference/http/function/header.xml:1.2 --- phpdoc-zh/reference/http/function/header.xml:1.1 Thu Nov 7 00:49:58 2002 +++ phpdoc-zh/reference/http/function/header.xml Fri Nov 8 01:15:21 2002 @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: avenger $ --> +<!-- EN-Revision: 1.8 Maintainer: Avenger Status: working --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.header"> <refnamediv> @@ -40,10 +42,8 @@ </para> <para> Í·²¿ÐÅÏ¢µÄ¸ñʽÓÐÁ½ÖÖÐÎʽ¡£Ò»ÖÖÇé¿öÊÇÒÔ×Ö·û ¡°<literal>HTTP/</literal>¡± (²»Çø·Ö´óСд)¿ªÍ·µÄ£¬which will be used to figure out the HTTP status - code to send¡£ÀýÈç,Èç¹ûÄã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. + code to send¡£ÀýÈç,Èç¹ûÄãʹÓÃµÄ WEB ·þÎñÆ÷ÊÇ Apache µÄ»°£¬Èç¹ûÒªÖÆ×÷Ò»¸öÕÒ²»µ½ÎÄÕµĴíÎó´¦ÀíÒ³Ãæ + (ʹÓà <literal>ErrorDocument</literal> Ö¸Áî)£¬Äã¿ÉÄÜ»áÐèÒªÓÃËüÀ´²úÉúһЩÊʵ±µÄ״̬´úÂë¡£ <informalexample> <programlisting role="php"> <![CDATA[ @@ -55,12 +55,11 @@ </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 + HTTP Í·²¿ÐÅϢͨ³£ÊÇÊ×Ïȱ»·¢Ë͵½¿Í»§¶ËµÄ£¬Ëü²¢²»¹ÜÄãµÄ <function>header</function> + º¯ÊýÊÇ·ñÊÇÔÚµÚÒ»ÐС£ÔÚͨ³£µÄÇé¿öÏÂThe status may be overridden by calling <function>header</function> with a new status line at any time unless the HTTP headers have already been sent. + ³ý·Ç HTTP Í·²¿ÐÅÏ¢ÒѾ±»·¢ËÍ¡£ </para> </note> <note> @@ -80,10 +79,8 @@ </note> </para> <para> - µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£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. + µÚ¶þÖÖÌØÊâÇé¿öÊÇÒÔ "Location:" ¿ªÍ·µÄÐÅÏ¢¡£Ëü²»Ö»ÊǼòµ¥µÄÏòä¯ÀÀÆ÷·¢ËÍһЩͷ²¿ÐÅÏ¢£¬Í¨³£Ëü»áÏòä¯ÀÀÆ÷·¢ËͳöÒ»¸ö <literal>REDIRECT</literal> + (302) (Ìø×ª) ״̬´úÂ룬³ý·ÇһЩÀàËÆÓÚ <literal>3xx</literal> µÄ״̬´úÂëÒѾ±»·¢ËÍ¡£ <informalexample> <programlisting role="php"> <![CDATA[ @@ -134,67 +131,50 @@ </informalexample> <note> <para> - Äã¿ÉÄܻᷢÏÖ¼´Ê¹ÄãûÓаÑÉϱߵĴúÂëÈ«²¿Êä³öÄãµÄÍøÒ³Ò²Ã»Óб»»º³åÆðÀ´¡£ÕâÊÇÒòΪһЩÓû§ÔÚËûÃǵÄä¯ÀÀÆ÷µÄÉèÖÃ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 - setting can be used to automatically generate the correct - caching-related headers when sessions are being used. + ÁíÍ⣬µ± session ÔÚ´úÂëÖб»Ê¹ÓÃʱ£¬ÀûÓà <function>session_cache_limiter</function> º¯ÊýºÍ + <literal>session.cache_limiter</literal> Ñ¡Ïî¿ÉÒÔ×Ô¶¯µÄ²úÉúÏà¹ØµÄ»º³åÇø¡£ </para> </note> </para> <para> - Remember that <function>header</function> must be - called before any actual output is sent, either by normal HTML - tags, blank lines in a file, or from PHP. It is a very common - error to read code with <function>include</function>, or - <function>require</function>, functions, or another file access - function, and have spaces or empty lines that are output before - <function>header</function> is called. The same problem exists - when using a single PHP/HTML file. + ÒªÀÎ¼Ç <function>header</function> + ҪʹÓÃÔÚÈκÎÍøÒ³Êä³öǰ¡£°üÀ¨Ò»Ð©·Ç HTML ±êÇ©ºÍ¿ÕÐж¼²»ÔÊÐíÔÚÆä֮ǰÊä³ö¡£ÔÚʹÓà <function>include</function> + ¡¢<function>require</function> º¯Êý»òһЩÆäËüµÄÎļþ´æÈ¡ÀຯÊýʱ£¬ÕâÊÇÒ»¸öºÜ³£·¸µÄ´íÎó¡£Í¬ÑùÔÚÒ»¸öµ¥¶ÀµÄ PHP/HTML + ÎļþÖÐÕâ¸ö´íÎóÒ²ºÜÆÕ±é¡£ <informalexample> <programlisting role="php"> <![CDATA[ <?php header ("Content-type: audio/x-pn-realaudio"); ?> -// Broken, note the blank line above +// ³ö´í£¬×¢Òâ header ǰµÄ¿Õ¸ñ ]]> </programlisting> </informalexample> <note> <para> - In PHP 4, you can use output buffering to get around this problem, - with the overhead of all of your output to the browser being buffered - in the server until you send it. You can do this by calling - <function>ob_start</function> and <function>ob_end_flush</function> - in your script, or setting the <literal>output_buffering</literal> - configuration directive on in your &php.ini; or - server configuration files. + ÔÚ PHP 4ÀÄã¿ÉÒÔͨ¹ýһЩÊä³ö»º³åº¯ÊýÀ´½â¾öÕâ¸öÎÊÌâ¡£ÕâÑù×ö£¬Äã¿ÉÒÔ°ÑËùÓеÄÊä³ö¶¼»º³åµ½·þÎñ£¬Ö±µ½ÄãÏÂÃüÁî·¢ËÍËüÃÇ¡£Äã¿ÉÒÔÔÚÄãµÄ´úÂëÖÐʹÓà <function>ob_start</function> ¼° <function>ob_end_flush</function> + À´ÊµÏÖÕâÑùµÄ¹¦ÄÜ£¬»òÕßͨ¹ýÐÞ¸ÄÄãµÄ &php.ini; ÖÐµÄ <literal>output_buffering</literal> + Ñ¡ÏîÀ´ÊµÏÖ£¬Ò²¿ÉÒÔͨ¹ýÐÞ¸ÄÄãµÄ·þÎñÆ÷ÅäÖÃÎļþÀ´ÊµÏÖ¡£ </para> </note> </para> <para> - If you want the user to be prompted to save the data you are - sending, such as a generated PDF file, you can use the <ulink - url="&url.rfc2183;">Content-Disposition</ulink> header to - supply a recommended filename and force the browser to display the - save dialog. + Èç¹ûÄãÏëÌáʾÓû§ÏÂÔØ²¢±£´æÒ»¸öÎļþ£¬ÀýÈçÒ»¸ö PDF + Îļþ£¬Äã¿ÉÒÔͨ¹ý·¢ËÍ <ulink url="&url.rfc2183;">Content-Disposition</ulink> ÐÅÏ¢À´Ê¹¿Í»§¶Ë»úÆ÷µ¯³öÏÂÔØ¶Ô»°¿òÀ´ÏÂÔØÄúÐèÒª´¦ÀíµÄÎļþ¡£ <informalexample> <programlisting role="php"> <![CDATA[ <?php -// We'll be outputting a PDF +// ÕâÑù½«»áÖ±½ÓÊä³öÒ»¸ö PDF Îļþ header("Content-type: application/pdf"); -// It will be called downloaded.pdf +// ÕâÑù×ö¾Í»áÌáʾÏÂÔØ PDF Îļþ downloaded.pdf header("Content-Disposition: attachment; filename=downloaded.pdf"); -// The PDF source is in original.pdf +// ÕâÊÇ original.pdf µÄÔ´Îļþ readfile('original.pdf'); ?> ]]> @@ -202,25 +182,22 @@ </informalexample> <note> <para> - There is a bug in Microsoft Internet Explorer 4.01 that prevents - this from working. There is no workaround. There is also a bug - in Microsoft Internet Explorer 5.5 that interferes with this, - which can be resolved by upgrading to Service Pack 2 or later. + Microsoft Internet Explorer 4.01 ÖеÄÒ»¸ö©¶´Ê¹µÃ¸Ã»úÖÆÎÞ·¨Õý³£¹¤×÷¡£ÔÚ Microsoft Internet Explorer 5 + ÖÐÕâ¸ö©¶´ÒÀÈ»´æÔÚ£¬Éý¼¶ Service Pack 2 ¼°ÆäÒÔºó°æ±¾ÖÐÕâ¸ö©¶´½«²»¸´´æÔÚ¡£ </para> </note> </para> <note> <simpara> - If <link linkend="ini.safe-mode">safe mode</link> is enabled the - uid of the script is added to the <literal>realm</literal> part - of the <literal>WWW-Authenticate</literal> header if you set - this header (used for HTTP Authentication). + Èç¹û PHP ÔËÐÐÔÚ°²È«Ä£Ê½ (<link linkend="ini.safe-mode">safe mode</link>) + Ï£¬µ±Ç°Ê¹ÓÃÕߵıêʶºÅ (UID) »á¸½¼Óµ½Í·²¿ÐÅÏ¢ <literal>WWW-Authenticate</literal> + µÄ <literal>realm</literal> ²¿·ÖÒ»Æð·¢ËÍ¡£(¿ÉÒÔÓÃÀ´×ö HTTP ÈÏÖ¤)¡£ </simpara> </note> <para> - See also <function>headers_sent</function>, - <function>setcookie</function>, and the section on - <link linkend="features.http-auth">HTTP authentication</link>. + ²Î¼û <function>headers_sent</function>, + <function>setcookie</function> + ¼° <link linkend="features.http-auth">HTTP authentication</link> Õ½Ú. </para> </refsect1> </refentry>