https://dev.webpages.dk/  
 
PHP htmlspecialchars
How to use htmlspecialchars:


Also be sure to read the pages about converting newlines to breaks.
And stripping HTML tags from a string: Or the second part of this page;
htmlspecialchars_decode that will show you what you need to decode the strings made with this 'htmlspecialchars'.

 htmlspecialchars

If you are to save some text in a database. And it may contain some HTML characters, then for your own sake, you should strip of those characters. Both cause they can result in a bad query when writing to the database. Also, if you let your users input text to your database, you should strip of special characters beofre the tyext is written to the DB.
You do it by using this code.
Then when you want to present the text from the database you can 'decode' the string, and get all you apostrophes, single and double quotes, and other characters looking to the way it is written, in the original text, as in the text these characters are converted into the HTML character codes.
Such charater codes can look like this; ' what is the HTML code for an apostrophe.
It will then when seen in the browser be shown as an apostrophe.

Remember also to read the page about the 'htmlspecialchars_decode'

Icons made by Freepik from www.flaticon.com This snippet is in two parts. First turn all tags and code into charatercodes, and then; decode them. This is part one.
03:33:40