I'm building a sign-in/up form and I have problems displaying HTML characters. When a user signs up, I use this function for the sign-up data and then insert it into the database.
function clearInput( $string) {
$string = stripslashes($string);
return htmlentities($string);
}
When a user signs-up with the name <p>hello</p>
it will look like this in the db: "&lt;p&gt;hello&lt;/p&gt"<br>
.
If the user signs-in and I var_dump
the name that is saved in the session it looks like this <br>'<p>hello</p>'
in the browser.
If I echo this <p>hello</p>
manually in the document, it displays this <p>hello\</p>
as it should normally.
Does someone know how it shows <p>hello</p>
when I var_dump
the session name?
I don't get your question but it will help you.
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars_decode($str);
This is some <b>bold</b> text.
$str = '<a href="https://www.test.com">test.com</a>';
echo html_entity_decode($str);
<a href="https://www.test.com">test.com</a>
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.