如何反转htmlentities()? [英] How to reverse htmlentities()?

查看:96
本文介绍了如何反转htmlentities()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于特殊字符,例如áéí,我可以拨打htmlentities():

For special characters like áéí, I can call htmlentities():

$mycaption = htmlentities($mycaption, ENT_QUOTES);

要获取相应的html实体:

To get the corresponding html entities:

áéí

如何将其恢复为áéí?

推荐答案

如果使用htmlentities()进行编码,则可以使用html_entity_decode()来逆转该过程:

If you use htmlentities() to encode, you can use html_entity_decode() to reverse the process:

将所有HTML实体转换为适用的字符.

Convert all HTML entities to their applicable characters.

html_entity_decode() htmlentities( ),因为它将字符串中的所有HTML实体转换为它们的适用字符.

html_entity_decode() is the opposite of htmlentities() in that it converts all HTML entities in the string to their applicable characters.

例如

$myCaption = 'áéí';

//encode
$myCaptionEncoded = htmlentities($myCaption, ENT_QUOTES);

//reverse (decode)
$myCaptionDecoded = html_entity_decode($myCaptionEncoded);

这篇关于如何反转htmlentities()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆