html_special_chars_decode() 函数用于将特殊 html 实体转换回字符。
以下是将要解码的 html 实体 -
&变为 &(与符号)
变为 (双引号)
& #039; 变为 ' (单引号)
& lt; 变为
> 变为 >(大于)
语法htmlspecialchars_decode(str,flags)
参数str - 要解码的字符串
flags - 指定如何处理引号以及要使用的文档类型。
以下是引号样式 -
ent_compat - 默认。仅解码双引号
ent_quotes - 解码双引号和单引号
ent_noquotes - 不解码任何引号
用于指定所使用的文档类型的附加标志 -
ent_html401 - 默认。将代码处理为 html 4.01
ent_html5 - 将代码处理为 html 5
ent_xml1 - 将代码处理为 xml 1ent_xhtml - 将代码处理为 xhtml
返回htmlspecialchars_decode () 函数返回转换后的字符串。
以下是示例 -
示例 现场演示
<?php$s = "<p>this -> "keyword in programming language</p>
";echo htmlspecialchars_decode($s);echo htmlspecialchars_decode($s, ent_noquotes);?>
以下是输出 -
输出<p>this -> "keyword in programming language</p><p>this -> "keyword in programming language</p>
以上就是在php中的htmlspecialchars_decode()函数的详细内容。
