Add & quot; // ignore & quot; after the output character encoding string, such as iconv ('utf-8', 'gb2312 // ignore ', $ content ), in this way, we ignore the characters that cannot be converted and avoid errors but cannot output them correctly (that is, no blank space or output)
After capturing web page data tonight and converting the code through the iconv function, an error is reported:
notice: iconv() [function.iconv]: detected an illegal character in input string ...
The error is that the content contains characters that do not support conversion.
There are two solutions:
1. extend the output character encoding range, such as iconv ('utf-8', 'gbk', $ content). This can be output correctly because gbk supports a wider range of characters;
2. add "// ignore" after the output character encoding string, such as iconv ('utf-8', 'gb2312 // ignore ', $ content ), in this way, you can ignore characters that cannot be converted and avoid errors but cannot output them correctly (that is, blank spaces and outputs ).