// Exemple : $text = "<script>console.log('salut')</script>"; echo $text; // Execute le script ! echo filter_var($text, FILTER_SANITIZE_FULL_SPECIAL_CHARS); // Pas interprèter $email = "jean(du22)@toto.fr"; echo $email; // output : jean(du22)@toto.fr echo filter_var($email, FILTER_SANITIZE_EMAIL); // output : jeandu22@toto.fr $number = "a10.5"; echo filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND); $arr = [ 'email' => 'jean(a)@<gmail>.com', 'text' => '<script>const a = 1</script>', 'number' => 'aa12aaa' ]; print_r(filter_var_array($arr, [ 'email' => FILTER_SANITIZE_EMAIL, 'text' => [ 'filter' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES ], 'number' => FILTER_SANITIZE_NUMBER_INT ])); $_POST = filter_input_array(INPUT_POST, [ 'firstname' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 'email' => FILTER_SANITIZE_EMAIL, 'date' => FILTER_SANITIZE_FULL_SPECIAL_CHARS ]);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter