The best way to store &(Ampersand) in MySQL database

后端 未结 5 1346
情书的邮戳
情书的邮戳 2020-12-19 09:14

I\'m building a category list and I\'m unsure how to store the Ampersand symbol in MySQL database. Is there any problem/disadvantage if I use \'&\'. Are the

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 10:07

    You should store it as & only if the field in the DB contains HTML (like some text & more). In which case you should be very careful about XSS.

    If the field contains some general data (like an username, title... etc) you should only escape it when you put it in your HTML (using htmlentities for example).

提交回复
热议问题