Last active
August 10, 2016 04:29
-
-
Save otkrsk/88db28e0ea4975ec421b2bf9056dd1cd to your computer and use it in GitHub Desktop.
Preserve HTML tags and formatting into a MySQL database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $str = "I 'am' a <strong>monster</strong>!"; | |
| // This will preserve the HTML tags (as well as the quotes) and make it safe to save into MySQL. | |
| echo htmlentities($str, ENT_QUOTES); | |
| // To display it with all its HTML glory, use html_entity_decode(). | |
| echo html_entity_decode($str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment