usa la funzione addslashes()
es:
codice:
<?
$testo="questo è il mio testo";
echo addslashes($testo);
?>