编程语言
首页 > 编程语言> > php – 为什么html_entity_decode()适用于第一个字符串,但不适用于第二个字符串?

php – 为什么html_entity_decode()适用于第一个字符串,但不适用于第二个字符串?

作者:互联网

$string1 = 'Cotton Lanyard ½"';
$string2 = 'Organic Cotton Lanyard ⅝"';

echo html_entity_decode($string1); //Cotton Lanyard ½"
echo html_entity_decode($string2); //Organic Cotton Lanyard ⅝"

不确定如何解决这个问题?

解决方法:

它适用于HTML5文档类型flag.

echo html_entity_decode($string2, ENT_HTML5);   // Organic Cotton Lanyard ⅝"

由于默认类型是ENT_HTML401(HTML 4.01),我认为这意味着没有在那里定义⅝实体.

标签:decoding,php,encoding,character-encoding,character
来源: https://codeday.me/bug/20190731/1586635.html