2 回答
Your problem is not with the htmlentity_decode($currency)
part, but with the json_encode
part. This will turn your euro symbol back to an htmlentity.
You could use json_encode($currency, JSON_UNESCAPED_UNICODE)
to force the use of the actual € symbol, but personally I think you are better of with sending the html entity. As some browser will see that as invalid code and you'll get unexpected results.
I checked that by not making any changes in PHP side and explicitly decoding the HTML entities in the javascript side, after receiving response, the problem gets fixed. I added this javascript function html_entity_decode()
(phpjs.org/functions/html_entity_decode) and called it before alerting the response, but that too did not work (then I added support for Euro in that function) and now it works..