I make a news page on php. Some html-tags are used when formatting text notes. What is the best way to proceed: write these tags to the database along with the text or use some symbols or codes that can be replaced with tags when output? How do people usually do this in popular cms and frameworks?

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants Visman , aleksandr barakin , D-side , Athari , Saidolim 21 Apr '16 at 20:23 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

    3 answers 3

    There is no need to replace tags, but you need to carefully add them to the database in order to avoid sql injection or an error, if you get, for example, an uneranted quote. Ideally, use the PDO prepared statement (if not using an ORM in which it is already provided).

      My opinion, I do not see the point in replacing tags before saving text. Because when you display the same tags and show you will need.

      I would check only the validity of the data before storing: that there are only allowed tags, that all tags are closed.

        Solved the problem by bb-codes. Editing with wysibb , while outputting - parsing with jbbcode