简体   繁体   English

用于将html实体转换为html特殊字符的PHP函数

[英]PHP function for converts html entities back to html special characters

I have this function for converts html entities back to html special characters: 我有这个函数将html实体转换回html特殊字符:

function html_entity_decode_utf8($value, $double_encode = TRUE) 

{
    return htmlspecialchars( (string) $value, ENT_QUOTES, "UTF-8", $double_encode);


}

Now, I need to Print this: 现在,我需要打印这个:

echo html_entity_decode_utf8('&zwnj');

Output is: 输出是:

&zwnj

Why htmlspecialchars notwork ?! 为什么htmlspecialchars不起作用?! how i can fix this? 我怎么能解决这个问题?

htmlspecialchars converts & into & htmlspecialchars&转换为& . To convert back, you need htmlspecialchars_decode : 要转换回来,你需要htmlspecialchars_decode

function html_entity_decode_utf8($value) 
{
    return htmlspecialchars_decode( (string) $value, ENT_QUOTES);
}

To see more options for using this function, check out the documentation . 要查看使用此功能的更多选项,请查看文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM