PHP FILTER_SANITIZE_STRING Filter
Definition and Usage
FILTER_SANITIZE_STRING filter removes or encodes unnecessary characters.
This filter removes data that may be harmful to the application. It is used to remove tags and delete or encode unnecessary characters.
- Name: "string"
- ID-number: 513
Possible options or flags:
- FILTER_FLAG_NO_ENCODE_QUOTES - This flag does not encode quotes
- FILTER_FLAG_STRIP_LOW - Remove characters with ASCII values below 32
- FILTER_FLAG_STRIP_HIGH - Remove characters with ASCII values above 32
- FILTER_FLAG_ENCODE_LOW - Encode characters with ASCII values below 32
- FILTER_FLAG_ENCODE_HIGH - Encode characters with ASCII values above 32
- FILTER_FLAG_ENCODE_AMP - Encode & character as &
Example
<?php
var_dump(filter_var($var, FILTER_SANITIZE_STRING
));
?>
Output:
string(13) "Bill Gates"