问题
In the following code:
$string1 = "function doesn't work as expected";
$string2 = html_entity_decode($string1);
$string2 still contains:
'
...after the call to html_entity_decode().
I've checked other SO threads on this topic, but haven't yet found the answer. What am I missing?
回答1:
The default flags for html_entity_decode
do not include single quotes. Try updating your flags argument to include ENT_QUOTES
and 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
来源:https://stackoverflow.com/questions/42286695/php-html-entity-decode-doesnt-decode-entity-as-expected