Basta utilizzare la funzione htmlspecialchars(). In caso contrario il browser interpreta quelle stringhe come tag html.