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 &
in your HTML source.
精彩评论