When data needs to be presented in Web pages, HTML special characters must be well protected Otherwise, data well not be presented properly, or the Web will become corrupted. This page allows you to learn and test the htmlspecialchars() function to protect embedded data in Web pages.
What are HTML special characters?
Most of you probably know that there are 3 basic HTML special characters reserved for HTML tags and entities: (<), (>) and (&).
But there are 2 more characters reserved for quoting tag attributes: (") and (').
If you don't protect those characters, your Web page will not work. Try the following HTML code, and see what happens:
Question: is it true that 23:59 < 00:00?<br> Answer: <input value='it's true.'>
How to use and test htmlspecialchars() PHP function?
htmlspecialchars(string) is the most commonly used PHP function to convert HTML special characters to safe formats:
To help you learn and test htmlspecialchars() function, FYIcenter.com has designed this online testing page. All you need to do is to enter the testing string in the form below and click the Start button. The converted string will be presented in the result area.
Other On-line Testing Pages by FYIcenter.com
FYIcenter.com has prepared some simple but very interesting on-line testing pages that are useful for your programming and testing tasks:
Each tutorial answers one commonly asked PHP programming question with a short, but precise and clear PHP script.