I
I
iOS Dav2016-07-05 13:10:45
PHP
iOS Dav, 2016-07-05 13:10:45

What is better, to save the user's post to the database by executing htmlentities() or not?

If not done, then we do EVERY TIME when visitors open a forum topic! This load on the server!!!!!!!!!!!!!!!
If done - what to do when the user tries to edit his post? after all, as far as I understand, the user needs the original text and not the text with extra characters that htmlentities () made

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yuras666, 2016-07-05
@yuras666

Most templating engines like twig always do something like <?php echo htmlspecialchars($var, ENT_QUOTES, 'UTF-8') ?> on output. So do not worry, the load on the server is small.

A
Andrey Burov, 2016-07-05
@BuriK666

Always keep the original text.
The parsed one can be cached. (although the costs for htmlentites/ htmlspecialchars are very small)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question