search

Home  >  Q&A  >  body text

php - About the display of htmlentities

$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

怪我咯怪我咯2837 days ago849

reply all(5)I'll reply

  • 过去多啦不再A梦

    过去多啦不再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

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:07:25

    Right click -> View web page source code

    reply
    0
  • 为情所困

    为情所困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.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味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>';

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:07:25

    https://zhidao.baidu.com/ques...

    reply
    0
  • Cancelreply