Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling all html tags, except some tags I want to allow

Tags:

html

php

tags

I want to allow tags like <b>, <h1>, <h2> but still disabling HTML in posts. How can I do that? can I do it with htmlspecialchars?

Thanks for your help , The site and the users are really helpful :).

like image 392
OverSpan Avatar asked Nov 17 '25 20:11

OverSpan


2 Answers

you can use strip_tags http://fr.php.net/manual/en/function.strip-tags.php the second arguments allows some tags.

like image 155
artragis Avatar answered Nov 20 '25 11:11

artragis


Use strip_tags().

http://php.net/manual/en/function.strip-tags.php

$stripped = strip_tags($text, "<b><h1><h2>");

Caveat emptor. There might be some security implications there.

like image 35
nalply Avatar answered Nov 20 '25 09:11

nalply



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!