HTML,PHP - Escape '<' and '>' symbols while echoing

后端 未结 8 1814
旧巷少年郎
旧巷少年郎 2020-12-02 00:15

I want to print following text as it is:

echo \"

But it is just showing \'AAAAA\' as output.

How can I esca

相关标签:
8条回答
  • 2020-12-02 00:26

    Use the htmlentities() function to convert into a plain text string.

    <?php
    echo htmlentities("<label> AAAAA");
    ?>
    
    0 讨论(0)
  • 2020-12-02 00:28
    echo htmlentities("<label> AAAAA");
    
    0 讨论(0)
  • 2020-12-02 00:31

    Use htmlspecialchars.

    <?php
        echo htmlspecialchars("abc & < >");
    ?>
    
    0 讨论(0)
  • 2020-12-02 00:32

    You should escape your especial characters for HTML.

    echo "&lt;label&gt; AAAA"

    http://www.w3schools.com/tags/ref_entities.asp

    0 讨论(0)
  • 2020-12-02 00:38
    echo "&lt;label&gt; AAAAA";
    
    0 讨论(0)
  • 2020-12-02 00:38

    Use HTML entities: &lt; for < and &gt; for >. Could be achieved using htmlspecialchars function: http://php.net/htmlspecialchars.

    Read more about HTML entities here: http://www.santagata.us/characters/CharacterEntities.html

    0 讨论(0)
提交回复
热议问题