What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other?
What are the differences between htmlspecialchars() and htmlentities() . When should I use one
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the PHP documentation for htmlentities:
From the PHP documentation for htmlspecialchars:
The difference is what gets encoded. The choices are everything (entities) or "special" characters, like ampersand, double and single quotes, less than, and greater than (specialchars).
I prefer to use
htmlspecialcharswhenever possible.For example: