Afin d'éviter les problèmes d'affichage et les injections il est recommandé d'encoder ou supprimer les caractères suivants pour les documents HTML et XML.
| Expression | Résultat |
|---|---|
| $string | Injection SQL';-- |
| htmlspecialchars($string) | Injection SQL';-- |
| htmlspecialchars($string,ENT_QUOTES) | Injection SQL';-- |
| htmlentities($string) | Injection SQL';-- |
| strip_tags($string) | Injection SQL';-- |
| strip_tags($string,'<a>') | Injection SQL';-- |
| filter_var($string, FILTER_SANITIZE_STRING) | Injection SQL';-- |
| filter_var($string, FILTER_SANITIZE_SPECIAL_CHARS) | Injection SQL';-- |
| filter_var($string, FILTER_SANITIZE_FULL_SPECIAL_CHARS) | Injection SQL';-- |
| addslashes($string) | Injection SQL\';-- |