Okay, so there's all these different string-escaping functions such as htmlentities(), mysql_real_escape_string(), addslashes()
But which should I use in what situation?
Resources and opinions please :)
<b>Something</b> to a HTML page, you will just see Something (i.e. the original text in bold) - you won't see the bold tags around it. Using htmlentities('<b>Something</b>') converts the code to <b>Something<b> so in the browser you see the triangle brackets.In summary:
which should I use in what situation?
htmlspecialchars(). For printing untrusted user input into browser.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With