File: http-inout.xml

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (136 lines) | stat: -rw-r--r-- 3,821 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 297028 $ -->

<chapter xml:id="mbstring.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <title>HTTP Input and Output</title>
 <para>
  HTTP input/output character encoding conversion may convert
  binary data also. Users are supposed to control character
  encoding conversion if binary data is used for HTTP
  input/output.
 </para>
 <note>
  <para>
   In PHP 4.3.2 or earlier versions, there was a limitation in this
   functionality that <literal>mbstring</literal> does not perform
   character encoding conversion in POST data if the
   <literal>enctype</literal> attribute in the <literal>form</literal>
   element is set to <literal>multipart/form-data</literal>.
   So you have to convert the incoming data by yourself in this case
   if necessary.
  </para>
  <para>
   Beginning with PHP 4.3.3, if <literal>enctype</literal> for HTML form is
   set to <literal>multipart/form-data</literal> and
   <literal>mbstring.encoding_translation</literal> is set to On
   in &php.ini; the POST'ed variables and the names of uploaded files
   will be converted to the internal character encoding as well.
   However, the conversion isn't applied to the query keys.
  </para>
 </note>
 <para>
  <itemizedlist>
   <listitem>
    <simpara>
     HTTP Input
    </simpara>
    <para> 
     There is no way to control HTTP input character
     conversion from a PHP script. To disable HTTP input character
     conversion, it has to be done in &php.ini;.
     <example>
      <title>
       Disable HTTP input conversion in &php.ini;
      </title>
      <programlisting role="php">
<![CDATA[
;; Disable HTTP Input conversion
mbstring.http_input = pass
;; Disable HTTP Input conversion (PHP 4.3.0 or higher)
mbstring.encoding_translation = Off
]]>
      </programlisting>
     </example>
    </para>
    <para>
     When using PHP as an Apache module, it is possible to
     override those settings in each Virtual Host directive in
     &httpd.conf; or per directory with &htaccess;. Refer to the <link
      linkend="configuration">Configuration</link> section and
     Apache Manual for details.
    </para>
   </listitem>
   <listitem>
    <simpara>
     HTTP Output
    </simpara>
    <para>
     There are several ways to enable output character encoding
     conversion. One is using &php.ini;, another
     is using <function>ob_start</function> with
     <function>mb_output_handler</function> as the 
     <literal>ob_start</literal> callback function.
    </para>
   </listitem>
  </itemizedlist>
 </para>
 <para>
  <example>
   <title>&php.ini; setting example</title>
   <programlisting>
<![CDATA[
;; Enable output character encoding conversion for all PHP pages

;; Enable Output Buffering
output_buffering    = On

;; Set mb_output_handler to enable output conversion
output_handler      = mb_output_handler
]]>
   </programlisting>
  </example>
 </para>
 <para>
  <example>
   <title>Script example</title>
   <programlisting role="php">
<![CDATA[
<?php

// Enable output character encoding conversion only for this page

// Set HTTP output character encoding to SJIS
mb_http_output('SJIS');

// Start buffering and specify "mb_output_handler" as
// callback function
ob_start('mb_output_handler');

?>
]]>
   </programlisting>
  </example>
 </para>
</chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->