PHP FILTER_SANITIZE_SPECIAL_CHARS Filter

What is FILTER_SANITIZE_SPECIAL_CHARS in PHP?

Explanation

PHP FILTER_SANITIZE_SPECIAL_CHARS is used to remove or strip or encode the special characters related to HTML-escapes characters based on ASCII values.

Name: "special_chars"
ID-number: 515

Options:


FILTER_FLAG_STRIP_LOW Strip characters with ASCII value below 32
FILTER_FLAG_STRIP_HIGH Strip characters with ASCII value above 32
FILTER_FLAG_ENCODE_HIGH Encode characters with ASCII value above 32

Example :


<?php
$val="Hscripts.com is webmaster & resources <hscripts.com> ";
echo filter_var($val,FILTER_SANITIZE_SPECIAL_CHARS);
?>

Result :

Hscripts.com is webmaster & resources <hscripts.com>
In page source
Hscripts.com is webmaster &#38; resources &#60; hscripts.com&#62;

In the above example, the given value in $val is encoded as in page source.

PHP Topics


Ask Questions

Ask Question