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

后端 未结 5 1320
情书的邮戳
情书的邮戳 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 09:50

    We store '&' into database fields all the time, it's fine to do so (at-least I've never heard an argument otherwise).

    If you're only ever using the string in a HTML page you could just store the HTML safe & version I suppose. I would suggest that storing '&' and escaping it when you read it would be better though (in-case you need to use the string in a non-HTML context in the future).

提交回复
热议问题