开发者

saving html & sign in database

I am trying to work开发者_如何学Go out, how I save & signs, I need this due to our customers business sometime have the & sign instead of and.

I thought it might be a preg thing but i am not sure


You shouldn't have any problems storing ampersands in your database (unless it's Oracle).

When displaying the data in an HTML page, make sure you encode it appropriately, eg

<?php echo htmlspecialchars($row['col'], ENT_COMPAT, 'UTF-8') ?>


There shouldn't be a problem storing ampersands in the database as &. When you retrieve the data from the database, you should convert HTML entities before displaying them in the browser. So & would become &amp; in your HTML source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜