Html kod temizleme.
function yaziSil ($text) { 
        $text = preg_replace("'<script[^>]*>.*?</script>'si", '', $text ); 
        $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)',$text ); 
        $text = preg_replace( '/<!--.+?-->/', '', $text ); 
        $text = preg_replace( '/{.+?}/', '', $text ); 
        $text = preg_replace( '/&nbsp;/', ' ', $text ); 
        $text = preg_replace( '/&amp;/', ' ', $text ); 
        $text = preg_replace( '/&quot;/', ' ', $text ); 
        $text = strip_tags($text); 
        $text = htmlspecialchars($text); 
        return $text; 
}
Kullanım şekli: yaziSil($mesaj);