PHP FILTER_SANITIZE_STRING filter
Definition and Usage
FILTER_SANITIZE_STRING filter to remove unwanted characters or encoded.
The filter remove those applications potentially harmful data. It is used to remove the label and delete unwanted characters or encoded.
- Name: "string"
- ID-number: 513
Possible options or flags:
- FILTER_FLAG_NO_ENCODE_QUOTES - This flag does not encode quotes
- FILTER_FLAG_STRIP_LOW - removal of characters in the ASCII value of 32 or less
- FILTER_FLAG_STRIP_HIGH - removal of characters in the ASCII value above 127
- FILTER_FLAG_ENCODE_LOW - encoded characters in the ASCII value of 32 or less
- FILTER_FLAG_ENCODE_HIGH - encoded characters in the ASCII value above 127
- FILTER_FLAG_ENCODE_AMP - the ampersand encoded as & amp;
Examples
<?php
$var="<b>Peter Griffin<b>";
var_dump(filter_var($var, FILTER_SANITIZE_STRING));
?>
$var="<b>Peter Griffin<b>";
var_dump(filter_var($var, FILTER_SANITIZE_STRING));
?>
Output code is as follows:
string(13) "Peter Griffin"
Complete PHP Filter Reference