At last, the emperor did not lose heart, but the answer still found me.
This is the case on the Internet.
CopyCodeThe Code is as follows: $ content = iconv ("UTF-8", "gb2312", $ content );
This is actually the opposite. It seems that UTF-8 is indeed converted to gb2312, but the actual operation is often ended in failure. Why?
The reason is actually very simple, because any function is executed incorrectly, and unfortunately iconv (); finally, an error occurs. Now let's give you the correct answer.
The real answer is:
Copy codeThe Code is as follows: $ content = iconv ("UTF-8", "gb2312 // ignore", $ content );
Simply add a // ignore to the end, and the iconv () function can ignore the error and continue execution.
Similarly, to replace gb2312 with UTF-8, you only need to write $ content = iconv ("gb2312", "UTF-8 // ignore", $ content );.