PHP FILTER_SANITIZE_SPECIAL_CHARS Filter
Definition and Usage
The FILTER_SANITIZE_SPECIAL_CHARS filter escapes special characters.
This filter is used to escape "<>&" and ASCII values below 32.
- Name: "special_chars"
- ID-number: 515
Possible Flags:
- FILTER_FLAG_STRIP_LOW - Remove ASCII values below 32
- FILTER_FLAG_STRIP_HIGH - Remove ASCII values above 32
- FILTER_FLAG_ENCODE_HIGH - Encode ASCII values above 32
Examples
<?php
var_dump(filter_var($url,FILTER_SANITIZE_SPECIAL_CHARS
));
?>
Output:
string(37) "Is Peter <smart> & funny?"
If you view the source code in your browser, you will see the following HTML:
string(37) "Is Peter <smart> & funny?"