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?
| SitePoint Sponsor |
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?
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.
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]
Use the markup language.. then you can do things like
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.Code:[L=tralala.com]Sweet link[EL]
However, if you really were desperate to ignore the HTML altogether you could break the text up into seperate variables I suppose.
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.





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!


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