在下面的代码中:
$string1 = "function doesn't work as expected";
$string2 = html_entity_decode($string1);
Run Code Online (Sandbox Code Playgroud)
$string2 仍然包含:
'
Run Code Online (Sandbox Code Playgroud)
...调用 html_entity_decode() 之后。
我已经检查过有关此主题的其他主题,但尚未找到答案。我缺少什么?
默认标志不包含html_entity_decode单引号。尝试更新您的 flags 参数以包含ENT_QUOTESand ENT_HTML5:
$string1 = "function doesn't work as expected";
echo $string2 = html_entity_decode($string1, ENT_QUOTES|ENT_HTML5);
// function doesn't work as expected
Run Code Online (Sandbox Code Playgroud)