The FILTER_SANITIZE_SPECIAL_CHARS filter performs HTML escaping of special characters.
This filter is used to escape "<>& and characters with ASCII values below 32.
Name: "special_chars"
ID-number: 515
Possible signs:
FILTER_FLAG_STRIP_LOW - strips characters with ASCII values below 32
FILTER_FLAG_STRIP_HIGH - remove characters with ASCII value above 32
FILTER_FLAG_ENCODE_HIGH - Encode characters with ASCII values above 32
<?php$url="Is Peter <smart> & funny?";var_dump(filter_var($url,FILTER_SANITIZE_SPECIAL_CHARS));?>
The browser output for the above code looks like this:
string(37) "Is Peter <smart> & funny?"
If you view the source code in a browser, you'll see the following HTML:
string(37) "Is Peter & lt; smart& gt; & amp; funny?"