mbstring.http.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 119 行

HTML
119
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>HTTP Input and Output</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mbstring.ja-basic.html">Basics of Japanese multi-byte encodings</a></div> <div class="next" style="text-align: right; float: right;"><a href="mbstring.supported-encodings.html">Supported Character Encodings</a></div> <div class="up"><a href="book.mbstring.html">Multibyte String</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>HTTP Input and Output</h1> <p class="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. </p> <blockquote><p><b class="note">Note</b>:      In PHP 4.3.2 or earlier versions, there was a limitation in this   functionality that <i>mbstring</i> does not perform   character encoding conversion in POST data if the   <i>enctype</i> attribute in the <i>form</i>   element is set to <i>multipart/form-data</i>.   So you have to convert the incoming data by yourself in this case   if necessary.  <br />     Beginning with PHP 4.3.3, if <i>enctype</i> for HTML form is   set to <i>multipart/form-data</i> and   <i>mbstring.encoding_translation</i> is set to On   in <var class="filename">php.ini</var> the POST&#039;ed variables and the names of uploaded files   will be converted to the internal character encoding as well.   However, the conversion isn&#039;t applied to the query keys.  <br /> </p></blockquote> <p class="para">  <ul class="itemizedlist">   <li class="listitem">    <span class="simpara">     HTTP Input    </span>    <p class="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 <var class="filename">php.ini</var>.     <div class="example">      <p><b>Example #1        Disable HTTP input conversion in <var class="filename">php.ini</var>      </b></p>      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">;;&nbsp;Disable&nbsp;HTTP&nbsp;Input&nbsp;conversion<br />mbstring.http_input&nbsp;=&nbsp;pass<br />;;&nbsp;Disable&nbsp;HTTP&nbsp;Input&nbsp;conversion&nbsp;(PHP&nbsp;4.3.0&nbsp;or&nbsp;higher)<br />mbstring.encoding_translation&nbsp;=&nbsp;Off</span></code></div>      </div>     </div>    </p>    <p class="para">     When using PHP as an Apache module, it is possible to     override those settings in each Virtual Host directive in     <var class="filename">httpd.conf</var> or per directory with <var class="filename">.htaccess</var>. Refer to the <a href="configuration.html" class="link">Configuration</a> section and     Apache Manual for details.    </p>   </li>   <li class="listitem">    <span class="simpara">     HTTP Output    </span>    <p class="para">     There are several ways to enable output character encoding     conversion. One is using <var class="filename">php.ini</var>, another     is using <a href="function.ob-start.html" class="function">ob_start()</a> with     <a href="function.mb-output-handler.html" class="function">mb_output_handler()</a> as the      <i>ob_start</i> callback function.    </p>   </li>  </ul> </p> <p class="para">  <div class="example">   <p><b>Example #2 <var class="filename">php.ini</var> setting example</b></p>   <div class="example-contents"><div class="cdata"><pre>;; Enable output character encoding conversion for all PHP pages;; Enable Output Bufferingoutput_buffering    = On;; Set mb_output_handler to enable output conversionoutput_handler      = mb_output_handler</pre></div>   </div>  </div> </p> <p class="para">  <div class="example">   <p><b>Example #3 Script example</b></p>   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Enable&nbsp;output&nbsp;character&nbsp;encoding&nbsp;conversion&nbsp;only&nbsp;for&nbsp;this&nbsp;page<br /><br />//&nbsp;Set&nbsp;HTTP&nbsp;output&nbsp;character&nbsp;encoding&nbsp;to&nbsp;SJIS<br /></span><span style="color: #0000BB">mb_http_output</span><span style="color: #007700">(</span><span style="color: #DD0000">'SJIS'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Start&nbsp;buffering&nbsp;and&nbsp;specify&nbsp;"mb_output_handler"&nbsp;as<br />//&nbsp;callback&nbsp;function<br /></span><span style="color: #0000BB">ob_start</span><span style="color: #007700">(</span><span style="color: #DD0000">'mb_output_handler'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>   </div>  </div> </p></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mbstring.ja-basic.html">Basics of Japanese multi-byte encodings</a></div> <div class="next" style="text-align: right; float: right;"><a href="mbstring.supported-encodings.html">Supported Character Encodings</a></div> <div class="up"><a href="book.mbstring.html">Multibyte String</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?