This is a very simple function, iconv (). However, this function cannot be converted successfully after many examples are found online. why? At last, the Emperor did not lose heart, but the answer still found me.
This is the case on the Internet.
The 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:
The 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 );.