Use htmlspecialchars
to output your strings
htmlspecialchars("I don't",ENT_QUOTES); // returns I don't
That will also take care of other HTML characters such as < & > as explained in the manual,
http://php.net/manual/en/function.htmlentities.php