Applica http://www.php.net/htmlentitites con la flag ENT_QUOTES.