First of all, i have gone through the related questions.. haven\'t found any answer.. I m using this code to display a message
echo \'Here goes your message wi
Have you tried the function addslashes()? It even uses your example.
I personally prefer the function htmlspecialchars() which does the same thing but has flags which let you specify its behavior.
like so:
echo htmlspecialchars("O'Rielly", ENT_QUOTES);
This shows the string properly on an HTML webpage.