utf8_decode 将字符串从 UTF-8 转换为 ISO-8859-1,替换无效或者无法表示的字符。 &warn.deprecated.function-8-2-0; &reftitle.description; #[\Deprecated] stringutf8_decode stringstring 该函数将字符串 stringUTF-8 编码转换为 ISO-8859-1。字符串中不是有效 UTF-8 字节或者不存在于 ISO-8859-1UTF-8 字符(即 U+00FF 以上的码点)将转化为 ? Many web pages marked as using the ISO-8859-1 character encoding actually use the similar Windows-1252 encoding, and web browsers will interpret ISO-8859-1 web pages as Windows-1252. Windows-1252 features additional printable characters, such as the Euro sign () and curly quotes ( ), instead of certain ISO-8859-1 control characters. This function will not convert such Windows-1252 characters correctly. Use a different function if Windows-1252 conversion is required. &reftitle.parameters; string UTF-8 编码的字符串。 &reftitle.returnvalues; 返回 string 的 ISO-8859-1 翻译。 &reftitle.changelog; &Version; &Description; 8.2.0 弃用此函数。 7.2.0 This function has been moved from the XML extension to the core of PHP. In previous versions, it was only available if the XML extension was installed. &reftitle.examples; 基础示例 ]]> &example.outputs; &reftitle.notes; 弃用和替代方案 从 PHP 8.2.0 开始,弃用此函数,并将在未来的版本中删除。应检查现有用途并用适当的替代方案。 类似的功能可以通过 mb_convert_encoding 实现,支持 ISO-8859-1 和许多其他字符编码。 ]]> &example.outputs; 根据安装的扩展,其他有效选项是 UConverter::transcodeiconv 以下都给出相同的结果: ]]> &example.outputs; 针对无效的字符串或者不能用 ISO 8859-1 表示的字符串,指定 '?' 作为 UConverter::transcode'to_subst' 选项,将获得同 utf8_decode 相同的结果。 '?'] ); var_dump($iso8859_1_string); ?> ]]> &example.outputs; &reftitle.seealso; utf8_encode mb_convert_encoding UConverter::transcode iconv