<p>This is Jhone's home.</p>
This is not display in my front site. but
When I use <p>This is Jhone\\'s home.</p>
It display.
I need to put without backslash. How can I do?
htmlspecialchars will help you out.
<?php
$str = "<p>This is Jhone's home.</p>";
echo htmlspecialchars($str);
?>
Using ENT_QUOTES
as the second argument to htmlspecialchars
will convert the quotations marks. Also, it is extremely important to provide the correct charset.
echo htmlspecialchars("This is Jhone's home.", ENT_QUOTES', 'UTF-8');
The translations that are performed are:
'&' (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 '>'
So if you view the source on the browser, your output will be this:
This is Jhone"s home.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.