牛牛在线工具

htmlspecialchars_decode()

收录 8868 个 PHP 函数,含用途说明与用法示例。

htmlspecialchars_decode()

将特殊字符实体(如 &、<、>等)转换回它们对应的字符

函数:htmlspecialchars_decode() 适用版本:PHP 4, PHP 5, PHP 7 用法: htmlspecialchars_decode(string $string, int $flags = ENT_COMPAT | ENT_HTML401): string 该函数用于将特殊字符实体(如 &、<、>等)转换回它们对应的字符。 参数: $string:要解码的字符串。 $flags(可选):指定解码过程中的选项。默认为 ENT_COMPAT | ENT_HTML401,表示使用 HTML 4.01 规范中的编码方式。 返回值: 返回解码后的字符串。 示例: $str = "This is a &lt;b&gt;bold&lt;/b&gt; text."; echo htmlspecialchars_decode($str); // 输出结果:This is a <b>bold</b> text. 在上面的示例中,我们传递了一个包含特殊字符实体的字符串给 htmlspecialchars_decode() 函数,它会将实体转换回对应的字符并返回解码后的字符串。最终输出结果为 "This is a bold text."。