PHP Dokumentation: Mbstring configuration
12. Januar 2010 von werner
Laufzeit-Konfiguration
Das Verhalten dieser Funktionen wirddurch Einstellungen in der php.ini beeinflusst.
| Name | Default | Changeable | Changelog |
|---|---|---|---|
| mbstring.language | "neutral" | PHP_INI_PERDIR | Available since PHP 4.3.0. |
| mbstring.detect_order | NULL | PHP_INI_ALL | Available since PHP 4.0.6. |
| mbstring.http_input | "pass" | PHP_INI_ALL | Available since PHP 4.0.6. |
| mbstring.http_output | "pass" | PHP_INI_ALL | Available since PHP 4.0.6. |
| mbstring.internal_encoding | NULL | PHP_INI_ALL | Available since PHP 4.0.6. |
| mbstring.script_encoding | NULL | PHP_INI_ALL | Available since PHP 4.3.0. |
| mbstring.substitute_character | NULL | PHP_INI_ALL | Available since PHP 4.0.6. |
| mbstring.func_overload | "0" | PHP_INI_SYSTEM | PHP_INI_SYSTEM in PHP <= 4.2.3; PHP_INI_SYSTEM | PHP_INI_PERDIR from PHP 4.3 through 5.2.6. Available since PHP 4.2.0. |
| mbstring.encoding_translation | "0" | PHP_INI_PERDIR | Available since PHP 4.3.0. |
| mbstring.strict_detection | "0" | PHP_INI_ALL | Available since PHP 5.1.2. |
Weitere Details und die Definitionen derPHP_INI_*-Konstanten finden Sie im php.php-dokumentation-ini Einstellungen.
Hier eine kurze Erklärung derKonfigurationsoptionen:
- mbstring.language string
The default national language setting (NLS) used in mbstring. Note that this option automagically defines mbstring.internal_encoding and mbstring.internal_encoding should be placed after mbstring.language in php.ini
- mbstring.encoding_translation boolean
Enables the transparent character encoding filter for the incoming HTTP queries, which performs detection and conversion of the input encoding to the internal character encoding.
- mbstring.internal_encoding string
Defines the default internal character encoding.
- mbstring.http_input string
Defines the default HTTP input character encoding.
- mbstring.http_output string
Defines the default HTTP output character encoding.
- mbstring.detect_order string
Defines default character code detection order. See also mb_detect_order().
- mbstring.substitute_character string
Defines character to substitute for invalid character encoding.
- mbstring.func_overload string
Overloads a set of single byte functions by the mbstring counterparts. See Function overloading for more information.
- mbstring.strict_detection boolean
Enables the strict encoding detection.
According to the » HTML 4.01 specification, Web browsers are allowed to encode a form being submitted with a character encoding different from the one used for the page. See mb_http_input() to detect character encoding used by browsers.
Although popular browsers are capable of giving a reasonably accurate guess to the character encoding of a given HTML document, it would be better to set the charset parameter in the Content-Type HTTP header to the appropriate value by header() or default_charset ini setting.
Beispiel #1 php.ini setting examples
; Set default languagembstring.language = Neutral; Set default language to Neutral(UTF-8) (default)mbstring.language = English; Set default language to English mbstring.language = Japanese; Set default language to Japanese;; Set default internal encoding;; Note: Make sure to use character encoding works with PHPmbstring.internal_encoding = UTF-8 ; Set internal encoding to UTF-8;; HTTP input encoding translation is enabled.mbstring.encoding_translation = On;; Set default HTTP input character encoding;; Note: Script cannot change http_input setting.mbstring.http_input = pass ; No conversion. mbstring.http_input = auto ; Set HTTP input to auto ; "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS"mbstring.http_input = SJIS ; Set HTTP2 input to SJISmbstring.http_input = UTF-8,SJIS,EUC-JP ; Specify order;; Set default HTTP output character encoding mbstring.http_output = pass ; No conversionmbstring.http_output = UTF-8 ; Set HTTP output encoding to UTF-8;; Set default character encoding detection ordermbstring.detect_order = auto ; Set detect order to autombstring.detect_order = ASCII,JIS,UTF-8,SJIS,EUC-JP ; Specify order;; Set default substitute charactermbstring.substitute_character = 12307 ; Specify Unicode valuembstring.substitute_character = none ; Do not print charactermbstring.substitute_character = long ; Long Example: U+3000,JIS+7E7E
Beispiel #2 php.ini setting for EUC-JP users
;; Disable Output Bufferingoutput_buffering = Off;; Set HTTP header charsetdefault_charset = EUC-JP ;; Set default language to Japanesembstring.language = Japanese;; HTTP input encoding translation is enabled.mbstring.encoding_translation = On;; Set HTTP input encoding conversion to autombstring.http_input = auto ;; Convert HTTP output to EUC-JPmbstring.http_output = EUC-JP ;; Set internal encoding to EUC-JPmbstring.internal_encoding = EUC-JP ;; Do not print invalid charactersmbstring.substitute_character = none
Beispiel #3 php.ini setting for SJIS users
;; Enable Output Bufferingoutput_buffering = On;; Set mb_output_handler to enable output conversionoutput_handler = mb_output_handler;; Set HTTP header charsetdefault_charset = Shift_JIS;; Set default language to Japanesembstring.language = Japanese;; Set http input encoding conversion to autombstring.http_input = auto ;; Convert to SJISmbstring.http_output = SJIS ;; Set internal encoding to EUC-JPmbstring.internal_encoding = EUC-JP ;; Do not print invalid charactersmbstring.substitute_character = none