17

I'm trying to figure out exactly what these php.ini settings do. What happens when they're set to different values? When are they necessary? When are they harmful?

As usual, the PHP manual is less than helpful.

EDIT: Just to clarify, I understand how character encodings work, and I understand how PHP's multi-byte functions differ from their single-byte counterparts. I'm looking for specifics on what the above settings do.

EDIT 2: OK, it looks like they actually do provide more documentation than just the page on runtime configuration, which just has one-line summaries. The first three of these have similarly-named functions, and there are more details on the pages that describe the function versions. I added links above.

EDIT 3: Adding a bounty. I'm looking for specific details on exactly what these settings do, especially the last three. What do they convert from and to, and when do they do it?

JW.
  • 50,691
  • 36
  • 115
  • 143
  • You're being sarcastic about the manual being less than helpful right? – Mike B Nov 07 '09 at 00:44
  • 4
    I think it is very helpful, as a manual for PHP. You also need to understand HTTP and character encodings to make sense of these settings, though. And the PHP manual is not a manual for either of these things. – Ben James Nov 07 '09 at 00:51
  • Re edit 2: I don't think the similarly-names functions are that helpful to your question. E.g., mb_language() implies that it only affects the encoding of email messages, whereas I get the impression that mbstring.language has a wider effect. And mb_http_input() just *detects* the encoding of data in the current HTTP request, which doesn't say anything about what the setting of mbstring.http_input does. – Michael Dyck Dec 09 '13 at 21:17

3 Answers3

7

You can change mbstring.language to whatever language you are using with. (Source)

language

; language for internal character representation.
mbstring.language = Neutral ; Set default language to neutral(UTF-8) (default)
mbstring.language = English
mbstring.language = Japanese
mbstring.language = Korean  ;For Korean market later

http_input

; http input encoding.
mbstring.http_input = pass
mbstring.http_input = auto
mbstring.http_input = UTF-8
mbstring.http_input = UTF-8, SJIS, EUC-JP

http_output

; http output encoding. mb_output_handler must be
; registered as output buffer to function
mbstring.http_output = pass
mbstring.http_output = UTF-8

encoding translation

; enable automatic encoding translation accoding to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do _not_ use automatic encoding translation for
;       portable libs/applications.
mbstring.encoding_translation = On
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
  • mbstring.http_input and mbstring.http_output have been deprecated as of PHP 5.6.0. If you are on PHP >= 5.6.0, use the 'default_charset' directive instead. – Adrian Wiik Dec 03 '19 at 20:30
3

The point is to support different character set encodings. There are a wide variety of encodings (ASCII, ANSI, UTF-8, etc) and each one has different character sets and number of bytes per character. The settings your looking at specify default encodings for different PHP functions.

PHP supplies a number of functions that help you deal with these different encodings properly. For an illustration, check out mb_strlen() vs strlen().

Short answer is, unless you're localizing your application's text, or communicating with systems with different encodings (your database included!), you probably don't need to worry about it.

DougW
  • 28,776
  • 18
  • 79
  • 107
2

I think everything is explained by the demonstration in this example:

http://fr2.php.net/manual/en/function.mb-internal-encoding.php#53265

Though it's not used in it, you can deduce the use of mbstring.http_input.

avetisk
  • 11,651
  • 4
  • 24
  • 37