Reputation: 1
<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?
Upvotes: 0
Views: 54
Reputation: 14649
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.
Upvotes: 0
Reputation: 11310
htmlspecialchars will help you out.
<?php
$str = "<p>This is Jhone's home.</p>";
echo htmlspecialchars($str);
?>
Upvotes: 1