SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: My Problem, Erm

Hybrid View

  1. #1
    SitePoint Zealot Ace Nova's Avatar
    Join Date
    Aug 2000
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im making a PHP/mySQL-based Content Management system and im going to use htmlspecialchars when im displaying content

    is there any way i can make a tag like [nospecialchars] and have everything inside it skipped by htmlspecialchars?
    Ace Nova
    Football Man
    InternetSprite.Com - Coming Soon!

  2. #2
    Nice Mug jer's Avatar
    Join Date
    Apr 2000
    Location
    Canada
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Taken from Kevin's tutorial:

    $joketext = htmlspecialchars($joketext);


    where $joketext is the text that you want to strip of htmlspecialchars. It'll change things like > into > (or is that one < ? oh well) etc.

    I suggest taking a look here:

    http://www.webmasterbase.com/article...id=228&pid=737

    That part of the tutorial also shows you how to use your own markup language (like vB Code, etc.) to help making displaying content easier. That is one of the best tutorials I've ever gone through, I suggest reading it all right from the beginning if you've got time.
    Jeremy Watts :: Co-Founder
    Modevia Web Services :: Experience the Difference.

  3. #3
    SitePoint Zealot Ace Nova's Avatar
    Join Date
    Aug 2000
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know that but is there a way i can get the htmlspecialchars to ignore the stuff within the tags,

    by tags i mean [ignore][/ignore]
    Ace Nova
    Football Man
    InternetSprite.Com - Coming Soon!

  4. #4
    Nice Mug jer's Avatar
    Join Date
    Apr 2000
    Location
    Canada
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the markup language.. then you can do things like

    Code:
    [L=tralala.com]Sweet link[EL]
    and it'll appear as Sweet link just like in normal HTML. It wouldn't really be ignoring it, it would strip the HTML and then add it in again.

    However, if you really were desperate to ignore the HTML altogether you could break the text up into seperate variables I suppose.
    Jeremy Watts :: Co-Founder
    Modevia Web Services :: Experience the Difference.

  5. #5
    SitePoint Zealot Ace Nova's Avatar
    Join Date
    Aug 2000
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sheesh i know you can make your own tags display like thta but say there is some html i want left alone when its display out of the db, no formatting to it, jus the raw code.
    Ace Nova
    Football Man
    InternetSprite.Com - Coming Soon!

  6. #6
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    string strip_tags (string str [, string allowable_tags])

    strip_tags() allows you to specify which tags not to strip from the string . But you would then have to str_replace() any odd '&' & '"' etc.

    Note that this will strip ALL HTML tags!

  7. #7
    SitePoint Addict Chris Roane's Avatar
    Join Date
    Jul 1999
    Location
    Helena, MT
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only reason why you would need to do that is if you don't know HTML very well. It wouldn't save you that much time anyway.

    But I guess that is just my preference.

    Chris Roane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •