gpt4 book ai didi

php - 如何反转 htmlentities()?

转载 作者:IT王子 更新时间:2023-10-29 00:38:58 26 4
gpt4 key购买 nike

对于像áéí这样的特殊字符,我可以调用htmlentities():

$mycaption = htmlentities($mycaption, ENT_QUOTES);

获取对应的html实体:

áéí

我怎样才能把它转回 áéí

最佳答案

如果你使用htmlentities()进行编码,你可以使用html_entity_decode()来反转这个过程:

html_entity_decode()

Convert all HTML entities to their applicable characters.

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);

关于php - 如何反转 htmlentities()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6465263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com