[英]How can I include special characters (or html content) in sqlite3 database with PHP
[英]how i used special characters in html content in php mysql
<p>This is Jhone's home.</p>
這不在我的前台顯示。 但
當我使用<p>This is Jhone\\'s home.</p>
顯示。
我需要不加反斜杠。 我能怎么做?
htmlspecialchars將幫助您。
<?php
$str = "<p>This is Jhone's home.</p>";
echo htmlspecialchars($str);
?>
使用ENT_QUOTES
作為htmlspecialchars
的第二個參數將轉換引號。 同樣,提供正確的字符集也非常重要。
echo htmlspecialchars("This is Jhone's home.", ENT_QUOTES', 'UTF-8');
執行的翻譯是:
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
"'" (single quote) becomes ''' (or ') only when ENT_QUOTES is set.
'<' (less than) becomes '<'
'>' (greater than) becomes '>'
因此,如果您在瀏覽器上查看源,則輸出將是這樣的:
This is Jhone"s home.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.