HOW TO DISABLE HTML CODES IN CHAT SCRIPT

Kate Smith

Total Post:24

Points:168
Posted by  Kate Smith
PHP 
PHP
 1371  View(s)
Ratings:
Rate this:
Hi Expert!

I Have Created A simple Chat script m using mysql fetch array to show the text written by users but a lot of users using html codes in text box and Changing my site configs [like Text color adding Images] please help me how to show the entered Html code as plaintext ?

Thanks in advance.

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How to Disable Html codes in chat script

    You can try as following

    You can use htmlentities() for that.

    An example of what it does:

    <?php
    $str = "A 'quote' is <b>bold</b>";

    // Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
    echo htmlentities($str);

    // Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
    echo htmlentities($str, ENT_QUOTES);
    ?>

    I hope it helpful for you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!