如何扭转htmlentities()?

Uli*_*Uli 55 php html-encode

对于像áéí这样的特殊角色,我可以打电话htmlentities():

$mycaption = htmlentities($mycaption, ENT_QUOTES);
Run Code Online (Sandbox Code Playgroud)

要获取相应的html实体:

áéí
Run Code Online (Sandbox Code Playgroud)

我怎样才能将其反转回áéí

hex*_*mal 97

如果您使用htmlentities()编码,则可以使用html_entity_decode()以反转该过程:

html_entity_decode()

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

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

例如

$myCaption = 'áéí';

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

//reverse (decode)
$myCaptionDecoded = html_entity_decode($myCaptionEncoded);
Run Code Online (Sandbox Code Playgroud)

  • @RNKushwaha相反函数的命名约定. (3认同)