php-doc-en/reference/mbstring/http-inout.xml
Jakub Vrana f453f7036c Add PHP tags to <programlisting>
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@301112 c90b9560-bf6c-de11-be94-00142212c4b1
2010-07-09 09:38:38 +00:00

136 lines
3.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<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.ini">
<![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
-->