note 15134 added to function.htmlspecialchars
| From: | jaalbers at dolfijn dot nl | Date: | Wed, 29 Aug 2001 12:25:19 +0000 |
| Subject: | note 15134 added to function.htmlspecialchars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17295@lists.php.net to get a copy of this message | ||
A better function to delete all html-tags is this one. It will delete all html-tags but not the text
between the tags. And when there are some tags not filtered it will be filtered through the
htmlspecialchars function.
function delete_html($form_name)
{
$form_name = str_replace("[", "", "$form_name");
$form_name = str_replace("]", "", "$form_name");
$not
="\"'*\abcdefghijklmnopqrstuvwxyz1234567890áéíóúýâêîôûàèìòùçäëïöüÿ=~`@#$%^&*()_{}\n\t\r\
/;:.!?,+-";
$form_name = eregi_replace("(</)+[$not]+(>)", "", "$form_name");
$form_name = eregi_replace("(<)+[$not]+(>)", "", "$form_name");
$form_name = str_replace("<", "", $form_name);
$form_name = str_replace(">", "", $form_name);
$form_name = htmlspecialchars($form_name);
return $form_name;
}
$message = delete_html($message);
http://www.php.net/manual/en/function.htmlspecialchars.php