Home > Article > Backend Development > PHP string encoding conversion example
2. Convert utf-8 encoded string to gb2312 encoded string
3. Convert the entire page This method works in all coding environments. In this way, the character set other than the first 128 characters (display characters) is represented by ncr (numeric character reference, such as "Chinese characters" will be converted into "Chinese characters"). This encoding can be used in any encoding environment. normal display. Add the following three lines of code to the head of the php file:
mb_internal_encoding(” gb2312″); // gb2312 The original encoding of the website mb_http_output("html-entities"); ob_start('mb_output_handler'); Using the mb_convert_encoding function requires enabling the mbstring (multi-byte string) extension of PHP. |