Home > DeveloperSection > Forums > How to Disable Html codes in chat script
Kate Smith
Kate Smith

Total Post:24

Points:168
Posted on    July-09-2013 3:08 AM

 PHP PHP 
Ratings:


 1 Reply(s)
 992  View(s)
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.



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    July-09-2013 4:39 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick