when i first started to do this, i wanted to remove all the html tags from a strin i had in my posts. this is an example:
<?
$string = "<h1>BIG HTML TAGS</h1>";
?>
$string = "<h1>BIG HTML TAGS</h1>";
?>
ok as you can see, this will output:
BIG HTML TAGS
but i dont want that, i want to stop and prevent html from being posted on my forums. i tried using htmlspecialchars() and htmlentities() but none did what i wanted.
but finally i found it, the function is called strip_tags()
so if i wanted to remove the <h1> tags from my string i would just simply do this:
<?
$string = "<h1>BIG HTML TAGS</h1>";
$string = strip_tags($string);
?>
$string = "<h1>BIG HTML TAGS</h1>";
$string = strip_tags($string);
?>
and this would be the ouput:
BIG HTML TAGS
No comments:
Post a Comment