$str
=
"
This is some <b>bold</b> text.
"
;
echo
htmlspecialchars_decode
(
$str
)
;
上面代码的 HTML 输出如下(查看源代码):
<
!
DOCTYPE
html
>
This is some
<
b
>
bold
</
b
>
text.
</
body
>
</
html
>
上面代码的浏览器输出如下:
This is some
bold
text.
定义和用法
htmlspecialchars_decode() 函数把一些预定义的 HTML 实体转换为字符。
会被解码的 HTML 实体是:
& 解码成 & (和号)
" 解码成 " (双引号)
' 解码成 ' (单引号)
< 解码成 < (小于)
> 解码成 > (大于)
htmlspecialchars_decode() 函数是
htmlspecialchars()
函数的反函数。
htmlspecialchars_decode(
string,flags
)
$str
=
"
Jane & 'Tarzan'
"
;
echo
htmlspecialchars_decode
(
$str
,
ENT_COMPAT
)
;