is it safe/fine to use stripslashes with htmlspecialchars
for some name like O'reily
actually slashes are already there in the names in database.
Yes, it is safe to do that.
can this be applied to other content output also.
or is it restricted to small strings only
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.