Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/clients/641f6c78b2fb4be841cb107cf09f47d4/web/tests/injections.php on line 23

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/clients/641f6c78b2fb4be841cb107cf09f47d4/web/tests/injections.php on line 24

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/clients/641f6c78b2fb4be841cb107cf09f47d4/web/tests/injections.php on line 25

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/clients/641f6c78b2fb4be841cb107cf09f47d4/web/tests/injections.php on line 26

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/clients/641f6c78b2fb4be841cb107cf09f47d4/web/tests/injections.php on line 27
PHP: Caractères spéciaux, injection & échappements | Kode.ch

Caractères spéciaux, injection & échappements

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.

Exemples de traitements de chaînes

Tester une chaîne

Expression Résultat
$string «ταБЬℓσ» : ' \ 1 < 2 & 4 + 1 > 3, "now" 20% off!
htmlspecialchars($string) «ταБЬℓσ» : &#039; \ 1 &lt; 2 &amp; 4 + 1 &gt; 3, &quot;now&quot; 20% off!
htmlspecialchars($string,ENT_QUOTES) «ταБЬℓσ» : &#039; \ 1 &lt; 2 &amp; 4 + 1 &gt; 3, &quot;now&quot; 20% off!
htmlentities($string) &laquo;&tau;&alpha;БЬℓ&sigma;&raquo; : &#039; \ 1 &lt; 2 &amp; 4 + 1 &gt; 3, &quot;now&quot; 20% off!
strip_tags($string) «ταБЬℓσ» : ' \ 1 < 2 & 4 + 1 > 3, "now" 20% off!
strip_tags($string,'<a>') «ταБЬℓσ» : ' \ 1 < 2 & 4 + 1 > 3, "now" 20% off!
filter_var($string, FILTER_SANITIZE_STRING) «ταБЬℓσ» : &#39; \ 1 3, &#34;now&#34; 20% off!
filter_var($string, FILTER_SANITIZE_SPECIAL_CHARS) «ταБЬℓσ» : &#39; \ 1 &#60; 2 &#38; 4 + 1 &#62; 3, &#34;now&#34; 20% off!
filter_var($string, FILTER_SANITIZE_FULL_SPECIAL_CHARS) &laquo;&tau;&alpha;БЬℓ&sigma;&raquo; : &#039; \ 1 &lt; 2 &amp; 4 + 1 &gt; 3, &quot;now&quot; 20% off!
addslashes($string) «ταБЬℓσ» : \' \\ 1 < 2 & 4 + 1 > 3, \"now\" 20% off!

Sources