Strip HTML from Strings and More

Quote from an interview with Michelangelo van Dam:

15) One function that you like (or which you tend to use frequently)

I think one particularly stands out: htmlentities($string, ENT_QUOTES, 'utf-8'); This function escapes output and ensures that your content is always in the same encoding (this example in utf-8), so you don’t get those crazy characters in your pages.

Function Behavior
htmlspecialchars() Replaces some characters with their HTML entities. Useful for filtering user form input.
htmlentities() Replaces all special characters with their HTML entities.
get_html_translation_table() Lets you know exactly what the replacements will be.
nl2br() Places the HTML break tag before newlines.
strip_tags() Strip HTML tags and PHP tags.
Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in PHP Form Processing, PHP String and tagged , , , . Bookmark the permalink.

Comment

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