XtScript Function: strip_tags
Remove HTML and PHP tags from a string.
XtScript strip_tags is a helpful and handy function if you want to easily remove all HTML tags in a string.
A few practical usage removing HMTL tags before sending it to the browser for example in comment box to remove all unwanted HTML tags, or when assigning text to a meta content.
XtScript strip_tags function basic syntax:
<!--parser:xtscript-->
call strip_tags $val=...; $allowable_tags=...
<!--/parser:xtscript-->
Optional argument in XtScript strip_tags function:
- $allowable_tags
Exclude HTML tags to keep it in the string.
Value: String contains allowed HTML tags
Learn XtScript strip_tags function from examples
Remove / filter HTML tags from a string using XtScript strip_tags function.
- Code:<!--parser:xtscript--> var $text = <a href="#"><b>A bold</b>, <u>underline</u>, and <s>strikethrough</s> text inside a hyperlink</a> var $filter_all = call strip_tags $val=$text; var $filter_some = call strip_tags $val=$text; $allowable_tags=<b><u> print Original: $text <br/> print Filtered: $filter_all <br/> print Filter keep bold and underline: $filter_some <!--/parser:xtscript-->- Result:
Original: A bold, underline, and strikethrough text inside a hyperlink
Filtered: A bold, underline, and strikethrough text inside a hyperlink
Filter keep bold and underline: A bold, underline, and strikethrough text inside a hyperlink
Filtered: A bold, underline, and strikethrough text inside a hyperlink
Filter keep bold and underline: A bold, underline, and strikethrough text inside a hyperlink
Last edited on