Browser-entered values are garbled in PHP programs

Publication Date:December 8, 2020

INFOMARTION > Browser-entered values are garbled in PHP programs


Garbled characters occurred when transitioning from the input screen to the confirmation screen in PHP.

Garbled text occurs when moving to the confirmation screen after entering text in the form. Garbled characters also occur when moving to the self screen due to an input check error. Since the server had just been built, I felt that something was missing from the PHP configuration, so I will describe what I found out at that time.

Table of Contents

  1. investigation (to determine the cause of something)
  2. summary

1. investigation (to determine the cause of something)

The following information was investigated to determine the cause of the problem.

1-1. survey

First, check the PHP settings (php.ini).


default_charset = "UTF-8"
mbstring.internal_encoding = UTF-8
mbstring.encoding_translation = On

The above is the case, and it looks OK. However, I could not identify the problem in the PHP source.

Once again, I checked php.ini for suspicious settings and found one suspicious setting.


mbstring.http_input = auto

It was unclear whether it was encoded in UTF-8 since it was set to "auto", so I changed it as follows to try it out.


mbstring.http_input = UTF-8

Garbled characters are resolved successfully. This setting is for the mbstring module, which is required when using multibyte strings in PHP. This is a setting for encoding received http requests.

2. summary

If you encounter garbled characters, suspect the following settings in php.ini. The default setting is "auto", so please check this when using mbstring to process multibyte strings.

Thank you for taking the time to read this to the end.


Please click here to go to the top page of INFORMATION.


Please click here to view the profile.

■For inquiries, please contact

For inquiries about the article, please contact us here.