$str = "A 'quote' is <b>bold</b>";
// Output: A 'quote' is <b>bold</b>
echo htmlentities($str);
Example from the official website, why when I use it, the page still displays A 'quote' is bold instead of the content in the comment
过去多啦不再A梦2017-05-16 13:07:25
If it’s just this piece of code, there will be no problem running it!
It depends on whether you have other codes that are affected
为情所困2017-05-16 13:07:25
Press F12 > Network > Response to view the parameters of the link response. The default browser will escape the ascii code for you.
淡淡烟草味2017-05-16 13:07:25
There is no problem with the running result because this kind of string ‘<’ is parsed by the browser; if you really want to output it like this
<?php
$str = "A 'quote' is <b>bold</b>";
// 输出: A 'quote' is <b>bold</b>
echo htmlentities(htmlentities($str)).'<br>';