Advertise with us

How to Disable Html codes in chat script

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.

Last updated:7/9/2013 4:39:45 AM

1 Answers


You can try as following

You can use htmlentities() for that.

An example of what it does:

$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.