Allan Smithee (bobalien) wrote in php,
Allan Smithee
bobalien
php

stripping HTML formatting

I'm doing something of a small content management system for a project I'm working on, and had a quick question about stripping html tags from database held text.

I plan on having a "news" section, updated via a web form or phpMyAdmin or something, but I would like the full news entries safe for HTML tags (bolding, italics, email links, etc). Additionally, I would like to display small 100-character or so blurbs of the "news" entries on other pages - my concern is that if a tag is opened before the 100-character cut-off and not closed, this will mess with the following code.

I've dabbled in solving this problem with little effort, and equally little success. Is there an easy way of stripping out HTML tags for a preview such as this? Am I better off not allowing HTML and providing my own tags, such as ::BOLD::here's some bold text::BOLD:: ? If this is the case, how do I prevent HTML tags at all?
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 7 comments