PHP: How to strip HTML tags, scripts, XML , PHP , and styles tags from string

Posted: May 4, 2011 in Browse ME!, Learn PHP, PHP Tricks, Web Development
Tags: , , , ,

Asslam-o-alikum,

The strip_tags() function in PHP will strip tags from a string. You can use one or two parameters with this function. Using only one parameter it will strip all tags found in a string. Using the second parameter will allow you to specify tags that should not get stripped from the input string.

Hello World"; $stripResult1 = strip_tags($myString); echo $stripResult1; // Returns "Hello World" echo " "; $stripResult2 = strip_tags($myString, ""); echo $stripResult2; // Returns "Hello World" ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s