Htmlspecialchars and stripslashes

hi all

is it safe/fine to use stripslashes with htmlspecialchars


htmlspecialchars(stripslashes($row['username']));

for some name like O’reily

actually slashes are already there in the names in database.

vineet

Yes, it is safe to do that.

hi cp

can this be applied to other content output also.

or is it restricted to small strings only

vineet

No you can do it to whatever output you need to generate, just keep in mind, if you generate HTML, htmlspecialchars() will convert the HTML tags into < and > so you won’t get HTML output, but rather your HTML will be shown as text on the page.