disabling html in forms
Posted: Wed Dec 18, 2002 4:33 am
Hey,
I'm working on a simple forum script, and I want to disable html in the posts. I have been using str_replace() to change the characters '<' '>' etc. to their text code. Is there an easier way to do this?
If there isn't another way, are these all the characters I should look out for? What else should I be careful of?
Thanks
I'm working on a simple forum script, and I want to disable html in the posts. I have been using str_replace() to change the characters '<' '>' etc. to their text code. Is there an easier way to do this?
Code: Select all
function format_content ($content)
{
$content = str_replace ("&", "&", $content);
$content = str_replace ("<", "<", $content);
$content = str_replace (">", ">", $content);
$content = str_replace (""", """, $content);
$content = str_replace ("'", "'", $content);
$content = str_replace ("!", "!", $content);
$content = str_replace ("|", "|", $content);
$content = str_replace ("<br>", "\n", $content);
return $content;
}Thanks