How to use FILTER SANITIZE STRING in PHP

This article describe about FILTER_SANITIZE_STRING Filter in PHP.
  • 5347

FILTER_SANITIZE_STRING Filter

For filter script or encode unwanted character FILTER_SANITIZE_STRING used.

Harmful data for your application removed by this filter. This filter used strip tags and remove or encode unwanted characters.

  • Name: "string"
  • ID-number: 513

Possible options and flags:

  • FILTER_FLAG_ENCODE_LOW - Encode characters with ASCII value below 32
  • FILTER_FLAG_ENCODE_HIGH - Encode characters with ASCII value above 127
  • FILTER_FLAG_ENCODE_AMP - Encode the & character to &amp
  • FILTER_FLAG_NO_ENCODE_QUOTES - This flag does not encode quotes
  • FILTER_FLAG_STRIP_LOW - Strip characters with ASCII value below 32
  • FILTER_FLAG_STRIP_HIGH - Strip characters with ASCII value above 127

Example

<html>
<body>
<?php
$var="<b>shoan Jamesleen<b>";
var_dump(filter_var($var, FILTER_SANITIZE_STRING));
?>
</body>
</html>

Output

pic3.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.