Home > Article > Backend Development > PHP character encoding problem: GB2312 VS UTF-8 solution_PHP tutorial
Look at the code:
Why? Why? Why? Why? What is garbled code? What is garbled code? Explain to me, what is the garbled code of %&!
Because there are no garbled characters in English but only Chinese garbled characters, I first thought about the encoding problem, and then suddenly remembered that the encoding of UTF-8 is that UTF-8 requires 3 bytes. Let’s treat it like a dead horse!
So print_r(str_split($string2,4)); the 4 in this sentence was replaced by 6, so - look at the result
Similarly, you can also try changing the UTF-8 of the encoded charset to GB2312. Because Unicode encoding requires 2 bytes, Gb2312 encoding can save 1/3 of the space than UTF-8. But if you want to be compatible with other languages such as Traditional Chinese, Korean, and Japanese, you need to use UTF-8.