mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-04-02 17:28:55 +00:00
144 lines
4 KiB
XML
144 lines
4 KiB
XML
![]() |
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!-- $Revision: 1.2 $ -->
|
||
|
|
||
|
<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>
|
||
|
<note>
|
||
|
<para>
|
||
|
PHP3-i18n users should note that <literal>mbstring</literal>'s output
|
||
|
conversion differs from PHP3-i18n. Character encoding is
|
||
|
converted using an output buffer.
|
||
|
</para>
|
||
|
</note>
|
||
|
</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:"../../../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
|
||
|
-->
|
||
|
|